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

luca cillo

Joined: Aug 27, 2002
Posts: 2
how can i call a servlet from a jsp?
i can set the action property of the form, i tried but didn't work out...
can i map my servlet in the web.xml file or something like that??
Ivan Matmati
Ranch Hand

Joined: Feb 26, 2003
Posts: 41
if you can't call a servlet from a form, it is not a matter of jsp.Either your url or your mapping of the url path to the servlet is wrong.Have a look.

No Gates!<p>SCPJ 1.4<br />SCWCD 1.4
Peekaboo Switchback
Ranch Hand

Joined: Feb 18, 2003
Posts: 33
You can use jsp:forward or you can use a redirect/forward enclosed in scriptlets.
<jsp:forward page="some relative URL"/>
<% request.getRequestDispatcher("your jsp/servlet url here").forward/redirect.
Since scriptlets get executed in _jspService(), they can forward requests to a servlet or jsp.
Parsuram panigrahi

Joined: Feb 18, 2003
Posts: 17
You can call a servlet from a JSP by forwarding the request to the JSP.

<JSP:forward page="/foo.servlet"/>
I agree. Here's the link:
subject: calling servlet from jsp