• 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

problem in retriving value

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

i have created 2 jsp .one is login page it having separate actionform and action .After the user submit the page i have to diaplay the username in my second jsp.
How can i do that in struts .Can i get that formbean in my second jsp?Should i share the same formbean for both jsp(Struts.config.xml scop=session)
like this? is there amy other way to do this ?

Thanks in advance .




 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Normally you'd store some sort of user object in the session so it's available throughout the entire application.
 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all in struts 2 there is no seprate actionforms and action both are included in Action.

Anyway in jsp you have to declare the element attributes with "s:" tag

<s:textfield name="fromDate" id="fromDate" theme="simple"/>

so in Action class you needed getters and setters for "fromDate". So automatically the action class takes the parameters from JSP.
Now to transfer to next page there are 2 ways
1) From there you can assign to some attributes and you can keep them in request or session.
2) Create a seprate action forms and assign this variables to new action form in Actionclass
 
syruss kumar
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks David ,kartik
Actually i set that user-name in session and i get it in the next page.
Is there any other way to do that in struts 1?
if i set that bean as request/session in action scope attribute in struts-config will work?
 
An elephant? An actual elephant. Into the apartment. How is the floor still here. Hold 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