| Author |
Best Way to Encode Response Parameter
|
Gabriel Cane
Ranch Hand
Joined: Mar 27, 2001
Posts: 39
|
|
I'm writing a servlet that will generate a list of links to files whose data I plan to display on the next page. Each link will contain the filename and JavaScript that will submit the form, whose action is to call the next servlet. Then I want to pass the filename parameter to the next servlet so that it can access the file. I know there are several effective methods for doing this, but I'd like to know which one is the best. 1) Create separate <FORM> tags to surround each link which will have either: 1 a) An ACTION attribute that will will contain a "?filename=<filename>.<ext>" String 1 b) A hidden input field that will contain the name/value pair. 2) Write a JavaScript function on the page that will take the parameter name and value as parameters to attach to the ACTION attribute in <FORM>. 3) Pass the parameter name and value to the Session object and retrieve them from the Session in the next servlet. 4) Something I haven't yet considered. What do you think?
|
Sun Certified Programmer for the Java 2 Platform
|
 |
Mike Curwen
Ranch Hand
Joined: Feb 20, 2001
Posts: 3695
|
|
You can fake a GET submission by placing the filename into the URL itself. No Javascript needed No FORM needed. The link would be something like:The servlet that generates this page can build these links dynamically. Something like: [ March 08, 2002: Message edited by: Mike Curwen ] [ March 08, 2002: Message edited by: Mike Curwen ]
|
 |
 |
|
|
subject: Best Way to Encode Response Parameter
|
|
|