File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Calling Servlet from JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Calling Servlet from JSP" Watch "Calling Servlet from JSP" New topic

Calling Servlet from JSP

Anupama Dande

Joined: May 09, 2003
Posts: 10
How do we call a Servlet from a JSP?
What are the steps involved?
Ravi Kumar Ravuru
Ranch Hand

Joined: Apr 18, 2002
Posts: 176
Hello Anupama Dande,
Calling a servlet from JSP as same as calling another JSP from JSP except if the servlet is mapped with different name..u have to call the servlet with the name specified at URL Mapping of the servlet at web.xml file.Hope this helps.
Malhar Barai
Ranch Hand

Joined: Aug 17, 2001
Posts: 399
Originally posted by Anupama Dande:
How do we call a Servlet from a JSP?
What are the steps involved?

What exactly do you want to do, as there are more than one way to call servlet from JSP.
Please give some more info.

Malhar Barai
SOA & Java Book
kavitha rama
Ranch Hand

Joined: Jun 18, 2003
Posts: 38
Hi, Its just like calling other JSP except that precede it with 'servlet'
ex: /servlet/page
where page is servlet, don't give any extension
Wendal Park
Ranch Hand

Joined: Aug 28, 2001
Posts: 39
Say if your servlet TestServlet is compiled under the package:
Then in your JSP, code something like this
<form name=yourName method=POST action="com.yourproject.servlet.TestServlet">
Make sure you have your app server and classpath set accordingly.

MSc, BSc, SCJP 1.4<br /> <img src="graemlins/banghead.gif" border="0" alt="[banghead]" /> SCBCD
I agree. Here's the link:
subject: Calling Servlet from JSP
It's not a secret anymore!