aspose file tools*
The moose likes Servlets and the fly likes Mapping problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Mapping problems" Watch "Mapping problems" New topic
Author

Mapping problems

Mike Phillip
Ranch Hand

Joined: Dec 05, 2007
Posts: 37
Hi, I trying to do an web app, and I'm having problems with the servlet mapping settings.

I that when the user hits http://localhost:8080/myapp/
it goes do the servlet I mapped, and it will redirect to a jsp file.

So I did:

<servlet>
<servlet-name>Serv1</servlet-name>
<servlet-class>com.myapp.MyIndexServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Serv1</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

it seems to work fine,

but is this the right way to map the first page to and servlet? could I do with a <welcome-file>

And if I have other servlets, and put other mapping, will they be affected by this patter?

thanks
Vinod K Singh
Ranch Hand

Joined: Sep 30, 2008
Posts: 198
There is no harm in the you choose to do the mapping. Similar behavior can be achieved by setting welcome file as well. When you configure more servlets they won't impact the existing ones as every servlet is required to have a unique URL pattern. Two servlets can not have same URL pattern though one servlet can serve many URL patterns.


My Blog
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
And the closest URL pattern will win.
Mike Phillip
Ranch Hand

Joined: Dec 05, 2007
Posts: 37
thanks guys, really helpful
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mapping problems
 
Similar Threads
404 error
Servlet Mapping doesn't work in Tomcat 5.5
404 Error
How to run servlet on Tomcat
HTTP Status 404 - /ch1/Serv1/