You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by pprun <ru...@hotmail.com> on 2009/12/08 22:16:35 UTC

Question on META-INF/context.xml

Hi, 

I am a novice to tomcat. I created WAR project in Eclipse called "Repromed".
Inside I specified META-INF/context.xml as following:

<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="Repromed" path="/Repromed" reloadable="true"
source="org.eclipse.jst.j2ee.server:Repromed">
	<Resource name="jdbc/rpsDB" 
	          auth="Container" 
	          type="javax.sql.DataSource"
              maxActive="100" 
              maxIdle="30" 
              maxWait="10000"
              removeAbandoned="true"
              removeAbandonedTimeout="60"
              logAbandoned="true"
              testOnBorrow="true" 
			  validationQuery="/* ping */ SELECT 1" 
              username="tomcat_user" 
              password="web01" 
              driverClassName="org.gjt.mm.mysql.Driver"
              url="jdbc:mysql://localhost:3306/repromed_master"/>
               		   
   	<Realm  className="org.apache.catalina.realm.DataSourceRealm" 
            dataSourceName="jdbc/rpsDB"
            userTable="users" 
            userNameCol="user_name"  
            userCredCol="user_pass" 
            userRoleTable="user_roles"  
            roleNameCol="role_name" 
            digest="MD5" 
            localDataSource="true"/>
	<WatchedResource>WEB-INF/web.xml</WatchedResource>
	<WatchedResource>META-INF/context.xml</WatchedResource>
</Context>

During the implementation, I was requested to deploy this Repromed.war as
the ROOT application to the localhost. I don't know how to convert
Repromed.war to ROOT.war. How to change the META-INF/context.xml? In
addition, do I need to change anything in the web.xml. 


Thank you for the help in advance. 

run


-- 
View this message in context: http://old.nabble.com/Question-on-META-INF-context.xml-tp26700904p26700904.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Question on META-INF/context.xml

Posted by pprun <ru...@hotmail.com>.
You are absolutely right, I decided to follow your perference. Thank you very
much for the suggestions. 

Regards,

run



Christopher Schultz-2 wrote:
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Run,
> 
> On 12/9/2009 10:57 AM, pprun wrote:
>> What about those links in the static HTML? How does it access to context
>> path? 
> 
> When it comes to static HTML/CSS, you have at least 4 options:
> 
> 1) Hard-code the path and remember to change them if you re-deploy (good
> luck)
> 2) Write a filter to re-write URLs in static files as they are being
> delivered (lots of work, slower HTTP responses)
> 3) Use a deployment strategy that re-writes the URLs during deployment
> (my preference)
> 4) Don't use static HTML/CSS
> 
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAksf47YACgkQ9CaO5/Lv0PA5MwCfX9OvWuxH+G6GlRx0xdQkjbTQ
> sKUAnifx+yOiQ21s6PzA+7sIG9GIWXxT
> =dzSM
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Question-on-META-INF-context.xml-tp26700904p26715825.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Question on META-INF/context.xml

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Run,

On 12/9/2009 10:57 AM, pprun wrote:
> What about those links in the static HTML? How does it access to context
> path? 

When it comes to static HTML/CSS, you have at least 4 options:

1) Hard-code the path and remember to change them if you re-deploy (good
luck)
2) Write a filter to re-write URLs in static files as they are being
delivered (lots of work, slower HTTP responses)
3) Use a deployment strategy that re-writes the URLs during deployment
(my preference)
4) Don't use static HTML/CSS

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAksf47YACgkQ9CaO5/Lv0PA5MwCfX9OvWuxH+G6GlRx0xdQkjbTQ
sKUAnifx+yOiQ21s6PzA+7sIG9GIWXxT
=dzSM
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Question on META-INF/context.xml

Posted by pprun <ru...@hotmail.com>.
Thanks a lot for this great tip. Can I ask one more question? 

What about those links in the static HTML? How does it access to context
path? 

Thanks again,

run


Christopher Schultz-2 wrote:
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Run,
> 
> On 12/8/2009 4:39 PM, pprun wrote:
>> I will remove docBase and path attributes. 
> 
> Did Eclipse put them in there?
> 
>> I do use some hard-coded "Repromed" in the css and javascript reference,
>> for
>> example: 
>> inside /Repromed/login.jsp i used <link href="/Repromed/css/repromed.css"
>> rel="stylesheet" />
>> 
>> I tried to replace it with relative URI for example <link
>> href="./css/repromed.css" rel="stylesheet" />
>> 
>> But it becomes a problem when the login page is shown in case of session
>> timeout.
> 
> [snip]
> 
>> Is there a way to get around it?
> 
> Try:
> 
> <link rel="stylesheet"
>      href="<%= request.getContextPath() %>/css/repromed.css">
> 
> Now, do this with all your links. Better yet:
> 
> <link rel="stylesheet"
>      href="<%= request.getContextPath() %><%=
> request.encodeURL("/css/repromed.css") %>">
> 
> This will make your webapp work when you are using sessions but your
> clients don't support cookies.
> 
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAkseyhcACgkQ9CaO5/Lv0PCJewCfc6K0m/RXKdoOMwjos9F35l09
> A9YAniNWBneqr4VeULkfXTIazw9PSRHE
> =ELAt
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Question-on-META-INF-context.xml-tp26700904p26712589.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Question on META-INF/context.xml

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Run,

On 12/8/2009 4:39 PM, pprun wrote:
> I will remove docBase and path attributes. 

Did Eclipse put them in there?

> I do use some hard-coded "Repromed" in the css and javascript reference, for
> example: 
> inside /Repromed/login.jsp i used <link href="/Repromed/css/repromed.css"
> rel="stylesheet" />
> 
> I tried to replace it with relative URI for example <link
> href="./css/repromed.css" rel="stylesheet" />
> 
> But it becomes a problem when the login page is shown in case of session
> timeout.

[snip]

> Is there a way to get around it?

Try:

<link rel="stylesheet"
     href="<%= request.getContextPath() %>/css/repromed.css">

Now, do this with all your links. Better yet:

<link rel="stylesheet"
     href="<%= request.getContextPath() %><%=
request.encodeURL("/css/repromed.css") %>">

This will make your webapp work when you are using sessions but your
clients don't support cookies.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkseyhcACgkQ9CaO5/Lv0PCJewCfc6K0m/RXKdoOMwjos9F35l09
A9YAniNWBneqr4VeULkfXTIazw9PSRHE
=ELAt
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Question on META-INF/context.xml

Posted by pprun <ru...@hotmail.com>.
Thank you very much for such quick response.

I will remove docBase and path attributes. 

I do use some hard-coded "Repromed" in the css and javascript reference, for
example: 
inside /Repromed/login.jsp i used <link href="/Repromed/css/repromed.css"
rel="stylesheet" />

I tried to replace it with relative URI for example <link
href="./css/repromed.css" rel="stylesheet" />

But it becomes a problem when the login page is shown in case of session
timeout.

Let's say user visited secure page /Repromed/adv/upload.jsp, then session
timed out, login.jsp is shown, 
reference to style sheet becomes <link href="/Repromed/adv/css/repromed.css"
rel="stylesheet" />

Is there a way to get around it? 

Thanks


Caldarale, Charles R wrote:
> 
>> From: pprun [mailto:runping_huang@hotmail.com]
>> Subject: Question on META-INF/context.xml
>> 
>> Inside I specified META-INF/context.xml as following:
>> 
>> <?xml version="1.0" encoding="UTF-8"?>
>> <Context docBase="Repromed" path="/Repromed" reloadable="true"
> 
> Remove the docBase and path attributes - they're not allowed when the
> <Context> element is in META-INF/context.xml
> 
>> I don't know how to convert Repromed.war to ROOT.war.
> 
> Usually, all you have to do is change the name of the .war file.  This is
> assuming you have not hard-coded "Repromed" within the webapp; if you
> have, you'll need to fix that.
> 
>> How to change the META-INF/context.xml?
> 
> No changes are needed to either META-INF/context.xml or WEB-INF/web.xml.
> 
>  - 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 unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Question-on-META-INF-context.xml-tp26700904p26701279.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Question on META-INF/context.xml

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: pprun [mailto:runping_huang@hotmail.com]
> Subject: Question on META-INF/context.xml
> 
> Inside I specified META-INF/context.xml as following:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <Context docBase="Repromed" path="/Repromed" reloadable="true"

Remove the docBase and path attributes - they're not allowed when the <Context> element is in META-INF/context.xml

> I don't know how to convert Repromed.war to ROOT.war.

Usually, all you have to do is change the name of the .war file.  This is assuming you have not hard-coded "Repromed" within the webapp; if you have, you'll need to fix that.

> How to change the META-INF/context.xml?

No changes are needed to either META-INF/context.xml or WEB-INF/web.xml.

 - 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 unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org