Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

servlet mapping takes over  RSS feed

 
Emil Nachev
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying a java application, MVC pattern, using servlets and jsp
--
the point is, when I mapp the servlets in web.xml, the server no longer reads my index.jsp.
moreover, when I add another servlet, the order into the web.xml matters which renders first.
---
I have added at the end of web.xml:

But still it wont start with the jsp page
Dont want the servlet to generate the first page

Best Regards
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you have a url pattern in your welcome file list?
 
Emil Nachev
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Why do you have a url pattern in your welcome file list?

Tried anything - I ve pasted it with <url-pattern> above
but it does not work with <welcome-file> only as well
 
Emil Nachev
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it ok, or it is in general odd, that the server doesnt read the index page?

I tried another way. Created init.servlet that redirects to my index page

response.sendRedirect("index.jsp");

now it could redirect to tomcat welcome page or whatever i put in tomcat ROOT
but when I append the content path

response.sendRedirect("/contentPath/index.jsp");

it goes for some infinite loop and the browser never reach the destination.
So, I am stuck both ways and cannot even start. Except if maybe put my web pages/views into the tomcat ROOT instead of my web app folder...
 
Tim Moores
Saloon Keeper
Posts: 3512
77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe you inadvertently mapped a servlet to / or /* ?
 
Emil Nachev
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Moores wrote:Maybe you inadvertently mapped a servlet to / or /* ?

yes it is /*

I set it to contentPath/ but still dont work
Now at least, whatever I set as a welcome file works
but from a button and action="servlet_name"
I cannot trigger the servlet. Stuck on this from yesterday, cant believe it

<form METHOD=POST ACTION="init">
UserName: <input type="text" name="uname" /><br />
Password: <input type="text" name="pwd" />
<P><INPUT TYPE=SUBMIT>
</form>

cannot triger the controler mapped as 'init'
The requested resource (/LaPizzeria/init) is not available.
where my content path = "LaPizzeria"
P.P.
FINALY works after few hours split yesterday and today, cant believe this stupid xml

<servlet-name>init</servlet-name>
<url-pattern>/</url-pattern>
should be '/' , not '/*'
 
Emil Nachev
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But now, when having two servlets, it executes the last one in web.xml no matter which name I call
this is insane!
all actions, no matter the name call the last servlet and thats all
trying to append the / with the controller folder name, the controller name itself, both..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!