Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Buttons with JSP

Status
Not open for further replies.

Larson

Programmer
Nov 7, 2002
5
0
0
CA
Does somebody know a JSP Script or Bean which kann create button on the fly?

I look for something which produces a Gif image after calling it with
/button.jsp?text=Home
 
Dear larson,

That is a job for a servlet. The servlet sets the HTTP content-type to image/gif then uses the Java Image class to draw the image then send the bits back to the browser in the HTTP content.

"But, that's just my opinion... I could be wrong".
-pete [sig][/sig]
 
If you want to create GIFs, use ACME labs excellent free gifencoder( and then do something like this:

Frame frame = null;
Graphics g = null;
FileOutputStream fileOut = null;

try
{
//create an unshown frame
frame = new Frame();
frame.addNotify();

//get a graphics region, using the frame

Image image = frame.createImage(WIDTH, HEIGHT);
g = image.getGraphics();

//manipulate the image
g.drawString("Hello world", 0, 0);

//get an ouputstream to a file
fileOut = new FileOutputStream("test.gif");
GifEncoder encoder = new GifEncoder(image, fileOut);
encoder.encode();
}
catch (Exception e)
{
;
}
finally
{
//clean up
if (g != null) g.dispose();
if (frame != null) frame.removeNotify();
if (fileOut != null) {
try { fileOut.close(); }
catch (IOException ioe) { ; }
}
}

I have used this code both in jsp & servlets & it works fine.. :)
 
Hi Larsen,
You can use a jsp to read a properties file which will contain your button information, in name value pair.
A helper class in java could read this and return a vector to the jsp.
The jsp then is free to interpret it on its own. Basically using table tags and populating the columns with a gif file or color or text, an good effect of buttons can be created.
This is quite possible, as i have personally used this in one of my projects.
For more information contact me at
aroravin@geodc.patni.com

Regards
Vinay Arora
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top