I am a newbie to web application development.
When the user clicks on any link in an html page, I want all the jsp
pages to be mapped to a servlet. Here is the small snippet of html
page:
<td width="350">
<a href="http://localhost:8080/EForms/Travel.jsp"
title="Business Services - x5890 - Travel Authorization Form"
target="_blank">
Travel Authorization Form<br>
</a>
</td>
And I mapped my jsps to the servlet as follows:
<servlet>
<servlet-name>ProcessAllForms</servlet-name>
<servlet-class>esign.ProcessAllForms</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ProcessAllForms</servlet-name>
<url-pattern>/ProcessAllForms</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ProcessAllForms</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
I am using Netbeans and when I deploy this application, nothing works.
The application doesn't even display the index.jsp.
If the remove the ".jsp servlet-mapping tag, everything works, but I
want my jsp's to go through a common Servlet.
Thanks.
Larry - 06 Apr 2006 20:38 GMT
When you use that pattern (*.jsp) you are telling the web server to
call your servlet (ProcessAllForms) when the browser requests any file
with an .jsp extension, including index.jsp. This means that all
browser calls to any JSP file will forward the request to your servlet
instead (not the JSP), and it's the servlet's process thats running
(init, doGet, doPost, etc.), not the .jsp. So when you try to load
index.jsp, it's actually forwarding the request to the servlet, and if
the servlet has no display properties (response.write) you ain't gonna
see anything :)
I'm thinking you want this servlet to run on any FORM POST call from
your JSP's, which is not what this would do.