Browser's URL with Struts & Tiles

A

Antti Nummiaho

I am using struts with tiles for my web application and I am wondering
how should I configure those to get the page url displayed on the
browser instead of the action path.

For example, in struts-config.xml I have:

<action path="/do_something"
type="foo.SomeAction">
<forward name="success"
path="somePage.page"/>
</action>

And in tiles-defs.xml:

<definition name="somePage.page" extends=".mainLayout">
<put name="pageTitle" value="someTitle" />
<put name="content"
value="/WEB-INF/tiles/contents/someContent.jsp"/>
</definition>

When the action do_something is invoked and the page is loaded, the url
that is shown in the browser is .../do_something.do while I would like
it to be something like .../someContent.jsp or .../somePage.page. Is
this possible? I tried putting redirect="true" attribute to the forward
tag, but it had no effect.
 
R

Raymond DeCampo

Antti said:
I am using struts with tiles for my web application and I am wondering
how should I configure those to get the page url displayed on the
browser instead of the action path.

For example, in struts-config.xml I have:

<action path="/do_something"
type="foo.SomeAction">
<forward name="success"
path="somePage.page"/>
</action>

And in tiles-defs.xml:

<definition name="somePage.page" extends=".mainLayout">
<put name="pageTitle" value="someTitle" />
<put name="content"
value="/WEB-INF/tiles/contents/someContent.jsp"/>
</definition>

When the action do_something is invoked and the page is loaded, the url
that is shown in the browser is .../do_something.do while I would like
it to be something like .../someContent.jsp or .../somePage.page. Is
this possible? I tried putting redirect="true" attribute to the forward
tag, but it had no effect.

The forwards above all happen on the server, the browser is totally
ignorant of them. So from the browsers point of view, all it did was
ask for /do_something.do and there is no reason to display anything else.

The moral: main your actions with the publicly visible URL you want not
the JSP pages.

HTH,
Ray
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top