Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

advice regarding URL for a servlet

 
Rex Norm
Ranch Hand
Posts: 41
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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.




 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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?
 
Hebert Coelho
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic