• Post Reply Bookmark Topic Watch Topic
  • New Topic

<servlet-mapping> issue  RSS feed

 
Philippe Ponceblanc
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I try to architect my website with a menu to redirect on the good pages JSP. My JSP pages have in common to have a servlet but there,
the automatic correction errors me the <servlet-mapping>, I must indicate the path in the Web.xml.
The completion does not indicate any reserved words to correct my problem.


this is my web.xml



Why eclipse returns an error on <servlet-mapping>
The Home page will contain the information "login" "password"
Then I could navigate my site.


Regards
Philippe
 
Paul Clapham
Sheriff
Posts: 22713
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand why you have the name of a JSP in the WEB-INF folder in there. What's that supposed to be for?

But anyway you said there was an error message. It would help greatly if you told us what the error message said.
 
Philippe Ponceblanc
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul !
Paul Clapham wrote:I don't understand why you have the name of a JSP in the WEB-INF folder in there. What's that supposed to be for?.

the place of JPS files is under WEB-INF ! Also I use the langague of the jstl !
Have you another place to put the JSP pages ?
Paul Clapham wrote: But anyway you said there was an error message. It would help greatly if you told us what the error message said.


this is the errors message
cvc-complex-type.2.4.a: Invalid content was found starting with element 'servlet-mapping'.
One of '{"http://java.sun.com/xml/ns/javaee":description, "http://java.sun.com/xml/ns/
javaee":display-name, "http://java.sun.com/xml/ns/javaee":icon, "http://java.sun.com/xml/ns/
javaee":servlet-name}' is expected.



Regards
philippe
 
Paul Clapham
Sheriff
Posts: 22713
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Philippe Ponceblanc wrote:the place of JPS files is under WEB-INF ! Also I use the langague of the jstl !
Have you another place to put the JSP pages ?


Of course that's where you would put the JSP files. But your web pages don't send requests to the JSPs, in fact they can't because WEB-INF is not accessible from the web pages. So you don't need to specify servlet mappings for the JSP because you aren't going to request them. Instead you're going to request a servlet which forwards to the JSP, right? You would map that servlet.

this is the errors message

cvc-complex-type.2.4.a: Invalid content was found starting with element 'servlet-mapping'.
One of '{"http://java.sun.com/xml/ns/javaee":description, "http://java.sun.com/xml/ns/
javaee":display-name, "http://java.sun.com/xml/ns/javaee":icon, "http://java.sun.com/xml/ns/
javaee":servlet-name}' is expected.


That tells you that the servlet-mapping element can have children named description, display-name, icon, and servlet-name. It can't have children named url-mapping. Your url-mapping elements would have to go somewhere else. If you needed them, that is. Which you don't.
 
Philippe Ponceblanc
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:
Philippe Ponceblanc wrote:the place of JPS files is under WEB-INF ! Also I use the langague of the jstl !
Have you another place to put the JSP pages ?


Of course that's where you would put the JSP files. But your web pages don't send requests to the JSPs, in fact they can't because WEB-INF is not accessible from the web pages. So you don't need to specify servlet mappings for the JSP because you aren't going to request them. Instead you're going to request a servlet which forwards to the JSP, right? You would map that servlet.

this is the errors message

cvc-complex-type.2.4.a: Invalid content was found starting with element 'servlet-mapping'.
One of '{"http://java.sun.com/xml/ns/javaee":description, "http://java.sun.com/xml/ns/
javaee":display-name, "http://java.sun.com/xml/ns/javaee":icon, "http://java.sun.com/xml/ns/
javaee":servlet-name}' is expected.


That tells you that the servlet-mapping element can have children named description, display-name, icon, and servlet-name. It can't have children named url-mapping. Your url-mapping elements would have to go somewhere else. If you needed them, that is. Which you don't.


if i remove the mapping of servlet the error is on <url-pattern> What do you think, I think I have to argue my servlets and beans to see if the error persists, I'm right or not?
 
Paul Clapham
Sheriff
Posts: 22713
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's been a few years since I worked with a web.xml file but I seem to remember that <servlet> and <servlet-mapping> are separate elements. You have the two elements mixed up together. But it might be a good idea if you tracked down a valid web.xml from your study materials to confirm that.
 
Mohammed Sardar.
Ranch Hand
Posts: 193
1
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

    1. The thing you are considering <servlet> & <servlet-mapping> as nested XML tags but somehow your (Tomcat) server container does not interpret the both.

    2. URL Pattern is something you type in browser's address bar . How an End User who is using your application knows the name of your JSP file?. So this can be any conventional URL name but not the actual JSP Page. This JSP name can be used inside the servlet class to load the page based on the result in servlet.

    Please have a look at below structure servlet.


Hope this helps and your mapping file should be alike as.





 
Philippe Ponceblanc
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks you very mutch Mohammed you are open my eyes !

Post/thread solved !
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!