×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Dynamic Buttons with JSP

Dynamic Buttons with JSP

Dynamic Buttons with JSP

(OP)
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

RE: Dynamic Buttons with JSP

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

RE: Dynamic Buttons with JSP

If you want to create GIFs, use ACME labs excellent free gifencoder(http://www.acme.com/), 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.. :)

RE: Dynamic Buttons with JSP

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close