This week's book giveaway is in the Java in General forum.
We're giving away four copies of Helidon Revealed: A Practical Guide to Oracle’s Microservices Framework and have Michael Redlich on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

servlet mapping takes over

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Bartender
Posts: 7645
178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe you inadvertently mapped a servlet to / or /* ?
 
Emil Nachev
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
 
I have gone to look for myself. If I should return before I get back, keep me here with this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic