Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling Servlet from JSP

 
Anupama Dande
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do we call a Servlet from a JSP?
What are the steps involved?
 
Ravi Kumar Ravuru
Ranch Hand
Posts: 176
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Ravi
 
Malhar Barai
Author
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Anupama Dande:
How do we call a Servlet from a JSP?
What are the steps involved?

Hi,
What exactly do you want to do, as there are more than one way to call servlet from JSP.
Please give some more info.
MB
 
kavitha rama
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Say if your servlet TestServlet is compiled under the package:
com.yourproject.servlet
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic