• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mapping problems

 
Mike Phillip
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And the closest URL pattern will win.
 
Mike Phillip
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks guys, really helpful
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic