aspose file tools*
The moose likes Servlets and the fly likes URL-Pattern mappings must contain /servlet/? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "URL-Pattern mappings must contain /servlet/?" Watch "URL-Pattern mappings must contain /servlet/?" New topic
Author

URL-Pattern mappings must contain /servlet/?

Michael Cropper
Ranch Hand

Joined: Sep 30, 2009
Posts: 137
Hi,

Following on from another thread (http://www.coderanch.com/t/550335/Tomcat/Tomcat-Shared-Server-Hosting) which I am bringing up in this area of the forums to check if there would be any reason behind the mappings behaving differently like this.

For example here are three URLs that all map to the exact same Servlet (the JSP file is the ultimate View for the Servlet)

http://www.website.co.uk/secure/dashboard.html
http://www.website.co.uk/secure/dashboard.jsp
http://www.website.co.uk/servlet/dashboard.do

Here are the following behaviours of these three different URLs when trying to access them.

The .html URL doesn't work at all - no content displaying at all, no indication of even getting to the first step (ie, no errors when not logged in)
The .jsp URL throws an error and says that it cannot find the '/includes/headincludes.jsp' file
The .do URL works!

How could this be?

The issue is that when I test all of the above URLs on my development machine, all is working fine. But when I upload to my webhost this just doesn't work, with the exception of the /servlet/ URL - which is why I believe this not to be an issue with the actual mappings - but just wanted to check with one of the Servlet experts here.

Thanks
Michael
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

No, mappings do not need to contain the word "servlet" -- in fact, doing so make one look rather naive. The ".do" pattern is also a holdover from Struts1 days and looks naive and amateurish.

Also, servlet mappings should not contain file types such as .jsp and .html. I'm not surprised that those are causing problems.

Modern mappings should be straight-forward and RESTful in nature -- so-called "friendly" URLs.

Without more knowledge of how you are mapping the servlet in the deployment descriptor, it's hard to say what the core problem may be.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Michael Cropper
Ranch Hand

Joined: Sep 30, 2009
Posts: 137
No, mappings do not need to contain the word "servlet" -- in fact, doing so make one look rather naive. The ".do" pattern is also a holdover from Struts1 days and looks naive and amateurish.


That's good to know.

Also, servlet mappings should not contain file types such as .jsp and .html. I'm not surprised that those are causing problems.

Modern mappings should be straight-forward and RESTful in nature -- so-called "friendly" URLs.


How do you mean 'RESTful'? I have not come across this term before, although it appears to be a Java framework.

Why would you not be surprised that using ".html" would be causing problems? There are no actual .html files located within the web-app. My understanding of how the files are processed is that all requests first go through web.xml and if a match is there, then it maps that URL to a Servlet. So for example, if I had "page1.html" as a Servlet mapping and also "page1.html" as an actual .html file, then I would never expect the .html file to actually run since the Servlet mapping would always take priority. Is that not the case?

Without more knowledge of how you are mapping the servlet in the deployment descriptor, it's hard to say what the core problem may be.


Please see below to give you an indication.



The .html extensions I have used are not required for the web-application so I can take these out to see if this solves the problem.

But based on my knowledge, I wouldn't have thought that would have made a difference.

Thanks
Michael
 
wood burning stoves
 
subject: URL-Pattern mappings must contain /servlet/?
 
Similar Threads
servlet configuration problem
Chapter 2 (HFSJ) notes , may be useful for anyone
Webapp works locally, but not on Server
Tomcat & Shared Server Hosting Issue
Why is this url-pattern combo not working?