Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to transfer variable values from one servlet to another?

 
ramesh kumar
Ranch Hand
Posts: 32
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
My program needs to transfer variables from one servlet to another. The following html page runs a servlet and the results
were hyperlinked. when I clik the hyperlinked values it has to
open another web page and as well it has to run a servlet.
I am giving my coding here.

//the servlet program is here.


The concept of the program is to display a file, viz. text file
from the server m/c, giving the correct name. the file name has
to check first whether it is file or directory, then if it is available it has to be shown as hyperliknked. after cliking the link the browser has to either download or display the whole file content.
[I added UBB CODE tags to your source code to make it more readable. Please try to use
them in the future. Learn more about UBB codes here - Ajith ]

[This message has been edited by Ajith Kallambella (edited January 11, 2001).]
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13048
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks to me like you could just include one or more hidden variables in your form. (incidently you left the </form> off)
<input type="hidden" name="foo" value="baz" >
Bill
 
Joe Paolangeli
Ranch Hand
Posts: 73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another choice would be to store the variables in the session object (HTTPSession) in the first servlet and retrieve them in the second servlet. Let me know if you need more details.
Also I am not sure why you are overriding the service method in your servlet. You should define the doPost method instead.
Good Luck,
Joe
 
rejieve alexander
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah ! Joe, Could u plz tell me how to pass the variables thro' HttpSessions..
Thanks
 
Joe Paolangeli
Ranch Hand
Posts: 73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will give you some sample code but it would also be beneficial for you to review the HttpSession Object in Servlet API Documentation. Here is the sample code:
First Servlet:

Second Servlet:

Hope this helps,
Joe
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic