Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to call Http Servlets from other Http Servlets

 
Bhasker Reddy
Ranch Hand
Posts: 176
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to call a Http Servlet from another Http Servlet.
But the page is not displayed.
I am clicking a link on the displayed webpage(from a servlet),
this link is supposed to take me to another Servlet.
can we call a servlet my just clicking a href link(like an html
page), how do you call a servlet from a servlet and pass parameters,
i will appreciate if someone can help me
thanks
 
Steve Fahlbusch
Bartender
Posts: 605
7
Mac OS X Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To have a servlet call a servlet (or jsp or html page).

This will call the servlet "servletname" passing all
parms passed to this servlet
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If what you're trying to do is have your first servlet generate html containing a hyperlink to a second servlet, then have the first servlet generate something like this:

And don't forget to urlEncode the address if you want to maintain session.
[This message has been edited by Miftah Khan (edited September 20, 2001).]
 
Bhasker Reddy
Ranch Hand
Posts: 176
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what do you mean by urlencode.,
how do you maintain sessions
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what do you mean by urlencode

Steve's response shows an example of how to urlEncode a web address.
how do you maintain sessions

You should read up on the servlet Session Tracking API. In particular, check out the javax.servlet.http.HttpSession interface, as well as the getSession() method of the javax.servlet.http.HttpServletRequest interface.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic