This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URL-Pattern mappings must contain /servlet/?

 
Michael Cropper
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64851
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Michael Cropper
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic