This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Servlets and the fly likes how to call Http Servlets from other Http Servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to call Http Servlets from other Http Servlets" Watch "how to call Http Servlets from other Http Servlets" New topic
Author

how to call Http Servlets from other Http Servlets

Bhasker Reddy
Ranch Hand

Joined: Jun 13, 2000
Posts: 176
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


Bhasker Reddy
Steve Fahlbusch
Bartender

Joined: Sep 18, 2000
Posts: 562
    
    7

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

Joined: Nov 22, 2008
Posts: 18944
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

Joined: Jun 13, 2000
Posts: 176
what do you mean by urlencode.,
how do you maintain sessions
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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.
 
wood burning stoves
 
subject: how to call Http Servlets from other Http Servlets