File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Best Way to Encode Response Parameter

 
Gabriel Cane
Ranch Hand
Posts: 39
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic