You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Eugene Wong <eu...@gmail.com> on 2007/03/20 03:58:34 UTC
[Deployment] Tomcat 5.5, Single war into multiple apps
Dear experts,
I have this foo.war created using netbeans and deployed to 2 apps in Tomcat,
namely fooTest and fooProduction. So I made 2 copies and renamed them to
fooTest.war and fooProduction.war and made changes to
\conf\Catalina\localhost\fooTest.xml and fooProduction.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/fooTest" reloadable="true">
<ResourceLink global="jdbc/fooTestDB" name="jdbc/fooTestDB"
type="javax.sql.DataSource"/>
</Context>
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/fooProduction" reloadable="true">
<ResourceLink global="jdbc/fooProductionDB" name="jdbc/fooProductionDB"
type="javax.sql.DataSource"/>
</Context>
So we have 2 apps which can be accessed from
http://localhost:8080/fooTest and
http://localhost:8080/fooProduction
Both apps run fine except for links which we hardcoded in our source, like
window.location = '/foo/logout.jsp';. Is there a way to config these apps to
redirect to their corresponding subdirectory when Tomcat see path the /foo ?
Any help would be great, thanks.
--
View this message in context: http://www.nabble.com/-Deployment--Tomcat-5.5%2C-Single-war-into-multiple-apps-tf3431207.html#a9565386
Sent from the Tomcat - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: [Deployment] Tomcat 5.5, Single war into multiple apps
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Eugene,
Eugene Wong wrote:
> I have this foo.war created using netbeans and deployed to 2 apps in Tomcat,
> namely fooTest and fooProduction. So I made 2 copies and renamed them to
> fooTest.war and fooProduction.war and made changes to
> \conf\Catalina\localhost\fooTest.xml and fooProduction.xml
Why not just put a context.xml into each WAR file and make them
self-contained?
> So we have 2 apps which can be accessed from
> http://localhost:8080/fooTest and
> http://localhost:8080/fooProduction
>
> Both apps run fine except for links which we hardcoded in our source, like
> window.location = '/foo/logout.jsp';. Is there a way to config these apps to
> redirect to their corresponding subdirectory when Tomcat see path the /foo ?
> Any help would be great, thanks.
You need to stop using hard-coded paths. Or, rather, you need to stop
hard-coding the /context path/. If you are using straight-up JSP, you
need to do this to all your URLs:
Change:
<a href="/foo/logout.jsp">
To this:
<a href="<%= request.getContextPath() %>/logout.jsp">
While you're at it, you should be doing this:
<a href="<%= request.getContextPath() %>
<%= response.encodeURL("/logout.jsp") %>">
This allows the container to encode the user's session id into the URL
so that users without cookies can still use sessions through your app.
Another option is to use one of the dozen or so competing tag libraries
to generate URLs for you. You generally do something like this:
<taglib:link href="/logout.jsp">log out</taglib:link>
...or something along those lines, and you get a link that uses the
correct context path (which could even be the root) and properly encodes
the URL for session-id tracking, too.
I know (or think I know?) that JSF, Struts, and a handful of other tag
libraries exist to do this stuff for you.
If you are using something other than JSP, you can use similar
direct-use of the API or similar tools (for instance, Velocity has
Velocity-tools, which can do all this, too).
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFF/1D39CaO5/Lv0PARAuQBAJ9V9+K7X90QHmUK/G8lPKLkpaWEOACfb2Zp
9IkdsowRkxWspRjEXbnTq0s=
=GFR/
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: [Deployment] Tomcat 5.5, Single war into multiple apps
Posted by Eugene Wong <eu...@gmail.com>.
Nevermind, in server.xml
--
View this message in context: http://www.nabble.com/-Deployment--Tomcat-5.5%2C-Single-war-into-multiple-apps-tf3431207.html#a9588211
Sent from the Tomcat - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: [Deployment] Tomcat 5.5, Single war into multiple apps
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Eugene Wong [mailto:eugenewyc@gmail.com]
> Subject: Re: [Deployment] Tomcat 5.5, Single war into multiple apps
>
> Where should I put <context> if not in seperate xml under
> conf/Catalina/localhost?
Where you have them is fine, just take out the path attribute. Do not
put <Context> elements in server.xml, since that makes them impossible
to update without restarting Tomcat. For details, see:
http://tomcat.apache.org/tomcat-5.5-doc/config/context.html
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: [Deployment] Tomcat 5.5, Single war into multiple apps
Posted by Eugene Wong <eu...@gmail.com>.
> <Context path="/fooTest" reloadable="true">
>
> <Context path="/fooProduction" reloadable="true">
>> Take out the path attributes - they're not allowed when a <Context>
>> element is in the conf/Catalina/localhost directory.
Where should I put <context> if not in seperate xml under
conf/Catalina/localhost?
I ended up replacement foo with request.getContextPath() and working fine.
Thanks.
--
View this message in context: http://www.nabble.com/-Deployment--Tomcat-5.5%2C-Single-war-into-multiple-apps-tf3431207.html#a9588114
Sent from the Tomcat - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: [Deployment] Tomcat 5.5, Single war into multiple apps
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Eugene Wong [mailto:eugenewyc@gmail.com]
> Subject: [Deployment] Tomcat 5.5, Single war into multiple apps
>
> \conf\Catalina\localhost\fooTest.xml and fooProduction.xml
>
> <Context path="/fooTest" reloadable="true">
>
> <Context path="/fooProduction" reloadable="true">
Take out the path attributes - they're not allowed when a <Context>
element is in the conf/Catalina/localhost directory.
> Both apps run fine except for links which we hardcoded in our
> source, like window.location = '/foo/logout.jsp';.
Can't you use relative links rather than absolute?
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org