Want to map all my jsp's to a common Servlet

P

Poorna

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.
 
L

Larry

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top