File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes forward action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "forward action" Watch "forward action" New topic

forward action

Sofia Paiva

Joined: Apr 07, 2004
Posts: 1
I'm using java 1.4, eclipse IDE and JBoss.
I have a index.jsp that forwards to a login.jsp
<logic:redirect forward="login"/>
in struts-config.xml i have:
<!-- Form Bean Definitions -->
<form-bean name="loginForm" type="Login"/>
<form-bean name="page1Form" type="Page1"/>
<form-bean name="page2Form" type="Page2"/>

<!-- Global forwards -->
<forward name="login" path="/"/>

<!-- Action Mapping Definitions -->
<action path="/login"
<action path="/Login"
<forward name="success" path="/pages/page1.jsp"/>
<action path="/page1"
<forward name="success" path="/pages/page2.jsp"/>
<action path="/page2"
<forward name="success" path="/pages/page3.jsp"/>

<!-- message resources -->
<message-resources parameter="ApplicationResources" null="false"/>


and each *.jsp have a form:
<html:form path="Login" ...>
<html:form path="page1" ...>
<html:form path="page2" ...>
I have a ActionForm,,
And a Action,, ...
When i do a submit in (the initial page), the page goes to form 'page1', but the address bar shows '', and when i do a submit on page1, the page goes to form 'page2', but the address bar shows '' and so on...
How is it possible to have the action displayed in the address bar with the same name of the form?
Please write it down, because i'm only working in struts for about a week or two, and i'm not quite understanding it yet. I've already tryed changing the names, but i must be doing something wrong, because it never works.
Thanks in advance.

Marc Peabody
pie sneak

Joined: Feb 05, 2003
Posts: 4727

The address bar displays what the user requested, not what the server responds with.
If the user requests the, that's what they see... no matter what page they end up at.
You're not doing anything wrong. It's just the way it works - a different paradigm.
If you really, really, really want it to do what you say:
You could have your send you to a prePage1.jsp which does nothing but forward you to another jsp or action with a more "appropriate" name.
This causes the user's browser to send an extra request to the server and thus display a different action or page in the address bar.
If you're only in Struts a week or so I recommend not worrying about it.

A good workman is known by his tools.
I agree. Here's the link:
subject: forward action
It's not a secret anymore!