File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes advice regarding URL for a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "advice regarding URL for a servlet" Watch "advice regarding URL for a servlet" New topic
Author

advice regarding URL for a servlet

Rex Norm
Ranch Hand

Joined: Dec 11, 2010
Posts: 41
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.




William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
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

Joined: Dec 11, 2010
Posts: 41
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

Joined: Dec 11, 2010
Posts: 41
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
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61010
    
  65

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?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Hebert Coelho
Ranch Hand

Joined: Jul 14, 2010
Posts: 754

Let me see if I understood, instead of http://localhost:8080/Ship2Storage/index.jsp you want to access by http://localhost:8080/index.jsp?


[uaiHebert.com] [Full WebApplication JSF EJB JPA JAAS with source code to download] One Table Per SubClass [Web/JSF]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: advice regarding URL for a servlet