This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JSP and the fly likes i get diffrent contextpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "i get diffrent contextpath " Watch "i get diffrent contextpath " New topic
Author

i get diffrent contextpath

amir taghvayi
Ranch Hand

Joined: Sep 16, 2011
Posts: 54
hi
i use tomcat5.32 + cpanel . i get diffrent context path in diffrent folder , for example :

i requested this Link " http://jbean.ir/colors/colrs.jsp " And give Back This Context Path " ContextPath: /colors "

And when i Requested This Link "http://jbean.ir/cal/cal2.jsp " give Back This Context Path " ContextPath : /cal "

Please Help(F1) !!

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

Each web app has its own context path. If you want two resources to have the same context path they must be in the same web app.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
amir taghvayi
Ranch Hand

Joined: Sep 16, 2011
Posts: 54
thanks Bear Bibeault
all file are Inside a one web app . I was confused why get different context path for different folder.
server.xml is :


<Host name="domain.com" appBase="/home/domain/public_html" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false" reloadable="true">
<Alias>www.domain.com</Alias>
<Context path="" reloadable="true" docBase="/home/domain/public_html" debug="1" privileged="true" autoDeploy="true" liveDeploy="true" />
<Context path="/manager" debug="0" privileged="true"
docBase="/usr/local/jakarta/tomcat/server/webapps/manager">
</Context>
</Host>
please help me !
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

Use code tags when posting code and markup.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

You'll need to show us how you have the web app laid out on disk.
amir taghvayi
Ranch Hand

Joined: Sep 16, 2011
Posts: 54
thank you
the structure of project is :



please help me !


Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

And how are you obtaining the context path?
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1016
I think the problem is that you are using the public_html directory as both an appBase for your host, and a docBase for your context.
Tomcat is geting confuzzled by this.

Because it is an app_base directory, and you have autoDeploy="true", any directory that you put in public_html becomes a seperate web application/web context - hence 'cal' and 'colors' show up as contexts.

Quick Solution: Edit server.xml to specify your app_base to be a different folder from the one you are using for your context. I would suggest something like '/home/appBase' to make sure it is well out of the way. Restart Tomcat.

Better Solution: Don't declare contexts in server.xml. The preferred method is described as part of the Tomcat documentation

amir taghvayi
Ranch Hand

Joined: Sep 16, 2011
Posts: 54
thanks Stefan Evans , is correct .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: i get diffrent contextpath
 
Similar Threads
site transfer context path problem
Apache Tomcat5 redirection. Status 404
JSP not able to find the servlet
How to get Context Path in Struts2 JSP?
easy uri context path req.getRequestURI()