User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 401,431 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,897 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 1033 | Replies: 1 | Solved
Reply
Join Date: Jul 2008
Posts: 16
Reputation: jeetudaljit is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
jeetudaljit jeetudaljit is offline Offline
Newbie Poster

How to Call Servlet from JSP

  #1  
Jul 23rd, 2008
Pl. help to call a servlet page which is in another directory from a jsp page.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,218
Reputation: peter_budo is a jewel in the rough peter_budo is a jewel in the rough peter_budo is a jewel in the rough 
Rep Power: 10
Solved Threads: 270
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: How to Call Servlet from JSP

  #2  
Jul 23rd, 2008
If servlets are not mapped with use of web.xml you call it like this from the form for example
<form action="http://localhost:8080/PROJECT_NAME/servlet/SERVLET_NAME_NO_FILE_EXTENSION" method="POST">
YOUR FORM HERE
</form>

The web.xml mapping will look like this
  1. <servlet>
  2. <servlet-name>SERVLET_NAME_YOU_WANT_TO_CALL_IT</servlet-name>
  3. <servlet-class>REAL_SERVLET_NAME_NO_FILE_EXTENSRION</servlet-class>
  4. </servlet>
  5.  
  6. <servlet-mapping>
  7. <servlet-name>SERVLET_NAME_YOU_WANT_TO_CALL_IT</servlet-name>
  8. <url-pattern>/A_NAME.jsp</url-pattern>
  9. </servlet-mapping>
Example:
REAL_SERVLET_NAME_NO_FILE_EXTENSRION is FrontController
SERVLET_NAME_YOU_WANT_TO_CALL_IT I want to be Front
A_NAME.jsp I want to be front.jsp
to call my FrontController I will do following
<form action="front.jsp" method="POST">
FORM CODE HERE
</form>
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JSP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JSP Forum

All times are GMT -4. The time now is 12:41 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC