wood burning stoves*
The moose likes Servlets and the fly likes servlet mapping acting differently after deploying to server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet mapping acting differently after deploying to server" Watch "servlet mapping acting differently after deploying to server" New topic
Author

servlet mapping acting differently after deploying to server

chris walker
Greenhorn

Joined: Dec 12, 2009
Posts: 6
Runs fine on local machine w/ tomcat 6 but has a problem on server running tomcat 6. I'm sure it is a configuration thing i am missing.

I map most of my servlets to jsps and they work fine. for example:

The problem I am having after deploying my app is url patterns with no extention or an extention other than .jsp. For example, I stream many images and have mapping like:

I get page not found when trying to access mydomain.com/images/profile_image.gif but, like i mentioned earlier, it works fine on local machine (localhost/images/profile_image.gif).

I ran a test where i changed the url pattern for another servlet from to and that resulted in a page not found when I tried to access mydomain.com/profile.asp.

One last test I did was to copy my conf/web.xml to the server but that did not solve the problem.


Any help will be much appreciated!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

What's the context path?

Also, mapping a usually static file type such as .gif to a dynamic resource will confused the heck out of anything that thinks that they should/could cache static resources. I'd avoid mapping any file type to a servlet -- that includes .jsp even though it's not static.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
chris walker
Greenhorn

Joined: Dec 12, 2009
Posts: 6
Bear Bibeault wrote:What's the context path?


Disclaimer: I've worked w/ java for a while but this is the first web app I've deployed where I have control over setting the context.

That being said, my context is:

I'm sure something should be there but it works this way for everything else(database, servlets mapped to jsps, etc).
Server is set up with a mydomain_com directory and a mydomain_com-webapps directory located in the tomcat home dir. I put everything in the mydomain_com directory (which I assume is part of the problem).
Bear Bibeault wrote:Also, mapping a usually static file type such as .gif to a dynamic resource will confused the heck out of anything that thinks that they should/could cache static resources. I'd avoid mapping any file type to a servlet -- that includes .jsp even though it's not static.

Interesting. So instead of mapping to profile.jsp just map to profile with no extention?

Thanks
chris walker
Greenhorn

Joined: Dec 12, 2009
Posts: 6
Checking my web host providers faq's i came across this statement:
In our standard installation, we map *.jsp and /servlet/* to your JVM. Everything else gets served by apache.

I think this is my problem.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

Eeeek!

Recommendation #1: find a provider who let's you have free reign over your stuff. All these types of restrictions make it easier on them by making it harder on you.

Recommendation #2: If #1 isn't feasbile, make sure all your mappings start with "/servlet" (how bogus! make me want to retch). See below about using "faux extensions".
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

chris walker wrote:That being said, my context is:

That maps everything to the root context, which is fine, but you should still code all your URLS with the context path pre-pended (even if its the empty string in thos case) so that the app still owrks regardless of where you put it.

Server is set up with a mydomain_com directory and a mydomain_com-webapps directory located in the tomcat home dir. I put everything in the mydomain_com directory (which I assume is part of the problem).

I'm not quite grokking this, but yeah, everything for a single app should be placed under a single folder hierarchy.

Interesting. So instead of mapping to profile.jsp just map to profile with no extention?

Yeah, when you start fooling around with "faux extensions" interesting things can start happening. And this case, "interesting" is not good.
chris walker
Greenhorn

Joined: Dec 12, 2009
Posts: 6
Thanks Bear.

I'm gonna take your advice and not map file extentions to a servlet.

I emailed my web host support to have them map files w/o an extention to the JVM.

Thanks again for the help and advice.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: servlet mapping acting differently after deploying to server
 
Similar Threads
Servlet works on WebSphere but not on Tomcat
Converting Tomcat app from Windows to Ubuntu
FORM authentication with TomCat 5 - jwsdp-1.4
FORM authentication with TomCat 5 - jwsdp-1.4
Deploy JSF Problem