• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

advice regarding URL for a servlet

 
Ranch Hand
Posts: 41
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think this is rather simple, but I can't seem to get this to work: I have a url as follows: http://localhost:8080/Ship2Storage/landing.s2s that works very well. I'd like to set it up where once I enter http://localhost:8080, I get to the servlet I want.

currently using:
Eclipse
Tomcat 5.5, run with workspace metadata
Struts 1.3.10
Tiles


my web.xml as follows:


Also my server.xml -- I realize that it is bad form to put the context in the Server.xml, but this is what Eclipse did (no excuse really).


and I have an index.jsp and an empty file named landing.s2s in my webapps directory (called WebContent in Eclipse):


And this also works well. however, I can't seem to eliminate the Ship2Storage prefix from the URL. that is, I currently call the site as follows :
http://localhost:8080/Ship2Storage/index.jsp and I'd like to eliminate the context path part. That is, I'd like to have the url be http://localhost:8080 only. I'm pretty sure this is possible, but I can't get it. I've messed around a lot with servlet config and servlet contexts (e.g. path=""), but to no avail. Maybe I have some problems to overcome in the Tiles and Struts files? All thoughts and even a pointer to some reading would be helpful.




 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By the Tomcat convention, if you put your web app under the ROOT directory it will become the app addressed by "/"

Bill
 
Rex Norm
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your post. Yeah, I did read that...and I'm coming to the conclusion that my problem is from using Tomcat within the Eclipse IDE (using WTP), and I can't figure out how to get it to be the root app. Eclipse has a directory structure that it uses for Tomcat, and I found it. I believe it is in the ${your workspace dir}\.metadata\.plugins\org.eclipse.wst.server.core\tmp0 in my install.

under this directory, the structure is as follows:



Can I simply move my app into the ROOT directory and configure the path in the <context> element? or do I have to find a way to do this from within the IDE? I don't want to move it and screw up the IDE, since I'm working on parts of it. My main issue is that I need to test it and debug it, and for that I need it to work from ROOT.

Anyone use the WTP server, running their app as root? Another workaround perhaps?

 
Rex Norm
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I also found this on the Wiki pages for WTP in Eclipse -- it seems that running from ROOT in WTP may be the issue:

For reference, the FAQ for can be found here.

no word in the FAQ about how to run from ROOT within Eclipse. Reading between the lines, the answer may be to run from the individual Tomcat installation instance rather than the virtual instance as provided by WTP.

_R
 
Sheriff
Posts: 67746
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
Why does it matter what happens when you run under Eclipse? Your app should be written to be independent of its context path, so that shouldn't matter. And when it gets deployed, it won't be under Eclipse, so what's the real issue?
 
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me see if I understood, instead of http://localhost:8080/Ship2Storage/index.jsp you want to access by http://localhost:8080/index.jsp?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic