You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Kan Leung, MK" <lm...@digitalempires.net> on 2001/02/21 15:56:58 UTC

auto reload of message resource and URL-rewrite

Hi,

Extracted from struts-example's walking tours:

"You can even reload the configuration and message resources without
restarting the container. See the end of the web.xml file for details."

* My 1st question is: how to achieve auto reload of message resources?

* My 2nd question is about "struts-example". Everytime when I load
"http://localhost/struts-documentation/", the image is never loaded
successfully at during first time. I viewed the source it the IMG_SRC is
"/struts-example/struts-power.gif;jsessionid=nhiizz1yq1". May I know why
URL-rewrite is invoked for my browser, which cookie capability is
properly enabled?

The image is loaded successfully when I pressed "reload" on my browser.
The string ";jsessionid*" is gone.


--
Kan LEUNG, M K
email: lmk@digitalempires.net
Digital Empires Company Limited





Re: auto reload of message resource and URL-rewrite

Posted by "Kan Leung, MK" <lm...@digitalempires.net>.
I got the URL loaded finally. I need to create the directory 'admin'
myself before calling .../admin/reload.do . Oops! Thanks Maya.

--
Kan LEUNG, M K
email: lmk@digitalempires.net
Digital Empires Company Limited


----- Original Message -----
From: "Maya Muchnik" <mm...@pumatech.com>
To: <st...@jakarta.apache.org>
Sent: Monday, February 26, 2001 9:44 PM
Subject: Re: auto reload of message resource and URL-rewrite


> Hi,
> I am sorry for my "stupidity". Need to read more careful email, and
what
> people ask. I have tried myself the following link:
> "http://localhost:8080/struts-example/admin/reload.do" and it works. I
can
> see messages about updating of ActionFormBean, ActionForward,...
properties
> on a command line (where I have started Tomcat)  and in browser window
the
> message - "OK".
> Maya
>
> Maya Muchnik wrote:
>
> > Kan is correct. I did have admin subdir under struts-example either.
> >
> > "Kan Leung, MK" wrote:
> >
> > > ----- Original Message -----
> > > From: "Craig R. McClanahan" <Cr...@eng.sun.com>
> > > To: <st...@jakarta.apache.org>
> > > Sent: Thursday, February 22, 2001 2:06 AM
> > > Subject: Re: auto reload of message resource and URL-rewrite
> > >
> > > > At the bottom of the struts-config.xml file for the example
> > > application, you
> > > > will see an action definition:
> > > >
> > > >     <action path="/admin/reload"
> > > >         type="org.apache.struts.actions.ReloadAction"/>
> > > >
> > > > which means you can send a request to the following URL
(assuming the
> > > normal
> > > > *.do mapping):
> > > >
> > > >     http://localhost:8080/struts-example/admin/reload.do
> > > >
> > > > and the Struts controller servlet will reload all of the
configuration
> > > files
> > > > and message resources (but not the Java classes -- you have to
ask
> > > your
> > > > servlet container to reload the app in order to accomplish
that).
> > > >
> > > > You can use any of these standard actions in your own
applications as
> > > well.
> > >
> > > Apache "page not found" error is experienced. I did include a
handler
> > > for *.do in tomcat-apache.conf file! I'm still unable to reload
resource
> > > file in runtime.
> > >
> > > ===CUT===
> > > Not Found
> > >
> > > The requested URL /struts-example/admin/reload.do was not found on
this
> > > server.
> > >
> > > Apache/1.3.12 Server at localhost Port 80
> > > ===CUT===
> > >
> > > --
> > > Kan LEUNG, M K
> > > email: lmk@digitalempires.net
> > > Digital Empires Company Limited
>



Re: auto reload of message resource and URL-rewrite

Posted by Maya Muchnik <mm...@pumatech.com>.
Hi,
I am sorry for my "stupidity". Need to read more careful email, and what
people ask. I have tried myself the following link:
"http://localhost:8080/struts-example/admin/reload.do" and it works. I can
see messages about updating of ActionFormBean, ActionForward,... properties
on a command line (where I have started Tomcat)  and in browser window the
message - "OK".
Maya

Maya Muchnik wrote:

> Kan is correct. I did have admin subdir under struts-example either.
>
> "Kan Leung, MK" wrote:
>
> > ----- Original Message -----
> > From: "Craig R. McClanahan" <Cr...@eng.sun.com>
> > To: <st...@jakarta.apache.org>
> > Sent: Thursday, February 22, 2001 2:06 AM
> > Subject: Re: auto reload of message resource and URL-rewrite
> >
> > > At the bottom of the struts-config.xml file for the example
> > application, you
> > > will see an action definition:
> > >
> > >     <action path="/admin/reload"
> > >         type="org.apache.struts.actions.ReloadAction"/>
> > >
> > > which means you can send a request to the following URL (assuming the
> > normal
> > > *.do mapping):
> > >
> > >     http://localhost:8080/struts-example/admin/reload.do
> > >
> > > and the Struts controller servlet will reload all of the configuration
> > files
> > > and message resources (but not the Java classes -- you have to ask
> > your
> > > servlet container to reload the app in order to accomplish that).
> > >
> > > You can use any of these standard actions in your own applications as
> > well.
> >
> > Apache "page not found" error is experienced. I did include a handler
> > for *.do in tomcat-apache.conf file! I'm still unable to reload resource
> > file in runtime.
> >
> > ===CUT===
> > Not Found
> >
> > The requested URL /struts-example/admin/reload.do was not found on this
> > server.
> >
> > Apache/1.3.12 Server at localhost Port 80
> > ===CUT===
> >
> > --
> > Kan LEUNG, M K
> > email: lmk@digitalempires.net
> > Digital Empires Company Limited


Re: auto reload of message resource and URL-rewrite

Posted by Maya Muchnik <mm...@pumatech.com>.
Kan is correct. I did have admin subdir under struts-example either.

"Kan Leung, MK" wrote:

> ----- Original Message -----
> From: "Craig R. McClanahan" <Cr...@eng.sun.com>
> To: <st...@jakarta.apache.org>
> Sent: Thursday, February 22, 2001 2:06 AM
> Subject: Re: auto reload of message resource and URL-rewrite
>
> > At the bottom of the struts-config.xml file for the example
> application, you
> > will see an action definition:
> >
> >     <action path="/admin/reload"
> >         type="org.apache.struts.actions.ReloadAction"/>
> >
> > which means you can send a request to the following URL (assuming the
> normal
> > *.do mapping):
> >
> >     http://localhost:8080/struts-example/admin/reload.do
> >
> > and the Struts controller servlet will reload all of the configuration
> files
> > and message resources (but not the Java classes -- you have to ask
> your
> > servlet container to reload the app in order to accomplish that).
> >
> > You can use any of these standard actions in your own applications as
> well.
>
> Apache "page not found" error is experienced. I did include a handler
> for *.do in tomcat-apache.conf file! I'm still unable to reload resource
> file in runtime.
>
> ===CUT===
> Not Found
>
> The requested URL /struts-example/admin/reload.do was not found on this
> server.
>
> Apache/1.3.12 Server at localhost Port 80
> ===CUT===
>
> --
> Kan LEUNG, M K
> email: lmk@digitalempires.net
> Digital Empires Company Limited


Re: auto reload of message resource and URL-rewrite

Posted by "Kan Leung, MK" <lm...@digitalempires.net>.
----- Original Message -----
From: "Craig R. McClanahan" <Cr...@eng.sun.com>
To: <st...@jakarta.apache.org>
Sent: Thursday, February 22, 2001 2:06 AM
Subject: Re: auto reload of message resource and URL-rewrite


> At the bottom of the struts-config.xml file for the example
application, you
> will see an action definition:
>
>     <action path="/admin/reload"
>         type="org.apache.struts.actions.ReloadAction"/>
>
> which means you can send a request to the following URL (assuming the
normal
> *.do mapping):
>
>     http://localhost:8080/struts-example/admin/reload.do
>
> and the Struts controller servlet will reload all of the configuration
files
> and message resources (but not the Java classes -- you have to ask
your
> servlet container to reload the app in order to accomplish that).
>
> You can use any of these standard actions in your own applications as
well.

Apache "page not found" error is experienced. I did include a handler
for *.do in tomcat-apache.conf file! I'm still unable to reload resource
file in runtime.

===CUT===
Not Found

The requested URL /struts-example/admin/reload.do was not found on this
server.

Apache/1.3.12 Server at localhost Port 80
===CUT===


--
Kan LEUNG, M K
email: lmk@digitalempires.net
Digital Empires Company Limited



Re: auto reload of message resource and URL-rewrite

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
"Kan Leung, MK" wrote:

> Hi,
>
> Extracted from struts-example's walking tours:
>
> "You can even reload the configuration and message resources without
> restarting the container. See the end of the web.xml file for details."
>
> * My 1st question is: how to achieve auto reload of message resources?
>

At the bottom of the struts-config.xml file for the example application, you
will see an action definition:

    <action path="/admin/reload"
        type="org.apache.struts.actions.ReloadAction"/>

which means you can send a request to the following URL (assuming the normal
*.do mapping):

    http://localhost:8080/struts-example/admin/reload.do

and the Struts controller servlet will reload all of the configuration files
and message resources (but not the Java classes -- you have to ask your
servlet container to reload the app in order to accomplish that).

You can use any of these standard actions in your own applications as well.

>
> * My 2nd question is about "struts-example". Everytime when I load
> "http://localhost/struts-documentation/", the image is never loaded
> successfully at during first time. I viewed the source it the IMG_SRC is
> "/struts-example/struts-power.gif;jsessionid=nhiizz1yq1". May I know why
> URL-rewrite is invoked for my browser, which cookie capability is
> properly enabled?
>
> The image is loaded successfully when I pressed "reload" on my browser.
> The string ";jsessionid*" is gone.

What servlet container are you using?  Some containers (such as Tomcat 3.2
running behind Apache) do not correctly deal with URL-rewritten session ids
unless you modify their configuration slightly -- in this case, you have to
define a "rewrite rule" in the Apache configuration file to make it work.

The details are in the Tomcat FAQ-O-MATIC, which you can reach via
<http://jakarta.apache.org>.  Search for an entry containing the words "URL
rewriting" and you will find the setup details.

> --
> Kan LEUNG, M K
> email: lmk@digitalempires.net
> Digital Empires Company Limited

Craig McClanahan



Re: auto reload of message resource and URL-rewrite

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
"Kan Leung, MK" wrote:

> * My 2nd question is about "struts-example". Everytime when I load
> "http://localhost/struts-documentation/", the image is never loaded
> successfully at during first time. I viewed the source it the IMG_SRC is
> "/struts-example/struts-power.gif;jsessionid=nhiizz1yq1". May I know why
> URL-rewrite is invoked for my browser, which cookie capability is
> properly enabled?
>

I didn't answer the other half of this question in my previous response, so
here is some background on why the URL rewriting takes place (even though
you have cookies enabled).

When a session is first created, the servlet container does not yet know
whether the client browser supports cookies.  Therefore, the only safe thing
to do on that initial response is to send the session id *both* ways (URL
rewriting and a cookie), and see what comes back in on the next request.  If
the cookie does not come back, the container says "aha, this client does not
support cookies, so I will continue to use rewriting".

>
> The image is loaded successfully when I pressed "reload" on my browser.
> The string ";jsessionid*" is gone.
>

That is because, on the subsequent request, your browser sent the session id
cookie along.  Therefore, the servlet container knows that you support
cookies, and it stops adding the session ID with URL rewriting.

>
> --
> Kan LEUNG, M K
> email: lmk@digitalempires.net
> Digital Empires Company Limited

Craig