• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

servlet mapping acting differently after deploying to server

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
chris walker
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic