Forums Register Login

<servlet-mapping> issue

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
 

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?
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.





+Pie Number of slices to send: Send
Hi,
Thanks you very mutch Mohammed you are open my eyes !

Post/thread solved !
Won't you be my neighbor? - Fred Rogers. tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1153 times.
Similar Threads
Chrome JSF Actions Problem
spring security roles issue
Exception preloading servlet
Tomcat - Form based declarative Security
Http 404 Error with servlet deployment. might be simple, but its irking
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 08:41:32.