Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

forward action

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
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-beans>
<form-bean name="loginForm" type="Login"/>
<form-bean name="page1Form" type="Page1"/>
<form-bean name="page2Form" type="Page2"/>
</form-beans>

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

<!-- Action Mapping Definitions -->
<action-mappings>
<action path="/login"
type="org.apache.struts.actions.ForwardAction"
parameter="/pages/Login.jsp"/>
<action path="/Login"
type="LoginAction"
name="loginForm"
scope="session"
input="/pages/Login.jsp">
<forward name="success" path="/pages/page1.jsp"/>
</action>
<action path="/page1"
type="Page1Action"
name="page1Form"
scope="request"
input="/pages/page1.jsp">
<forward name="success" path="/pages/page2.jsp"/>
</action>
<action path="/page2"
type="Page2Action"
name="page2Form"
scope="request"
input="/pages/page2.jsp">
<forward name="success" path="/pages/page3.jsp"/>
</action>
</action-mappings>

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

</struts-config>

and each *.jsp have a form:
<html:form path="Login" ...>
<html:form path="page1" ...>
<html:form path="page2" ...>
I have a ActionForm Login.java, Page1.java, Page2.java.
And a Action LoginAction.java, Page1Action.java, ...
When i do a submit in login.do (the initial page), the page goes to form 'page1', but the address bar shows 'Login.do', and when i do a submit on page1, the page goes to form 'page2', but the address bar shows 'page1.do' 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.
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The address bar displays what the user requested, not what the server responds with.
If the user requests the login.do, 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 login.do 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.
 
Humans and their filthy friendship brings nothing but trouble. My only solace is this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic