Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display form data in jsp after forward action (struts)

Status
Not open for further replies.

titanzero

Programmer
May 3, 2007
30
EU
Hi people

Not sure if this is the right forum as its a struts\jsp question.

I am new to Java web development. I know Java quite well (applets and command-line apps) but never used it for web tech. I am more used to developing in PHP. Moving over to Struts\JSP is proving harder than I thought. Anyway, here is my problem.

I have a simple form which asks for username and password. Upon submission of said form an Action is called which validates the form input and then forwards to a confirmation page (via the struts-config.xml). One page is used for a successful login and another for an unsuccessful login. All this works well and if the user inputs the username and password I have hard-coded into the Action they get redirected to another JSP page.

FORM --> ACTION --> FINAL JSP

What I need to know is how do I access the information that was entered into the form from the final JSP page? I simply want to display the name the user in-putted on the form.

In PHP I would do something like this

FORM -->
VALIDATE SCRIPT (set up session object to hold input) -->
FINAL PAGE (display info I want from session object)

As I understand it, the info I want my JSP page to access is already in a ActionForm (JavaBean) but I've no idea how to reference it from anything other than my Action object.

I searched around and could only find an example that uses the 'bean:write' tag. Eclipse tells me this is not a recognised tag and nothing is displayed.

I find all of this very unintuitive given that my background is in PHP. Maybe there is a nice tutorial someone knows of that will explain passing data around Struts\JSP web apps?

Thank you very much for your time :)
Andrew
 
Are you including the tag?

Code:
<%@taglib uri="[URL unfurl="true"]http://struts.apache.org/tags-bean"[/URL] prefix="bean" %>

Cheers,
Dian
 
Hi Dian

I figured that out now. I had lots more problems which I have now solved. My dev environment was set up wrong, missing includes, missing knowledge...mostly missing knowledge lol.

Once I've figured it all out I might write a tutorial for people moving over from PHP to Java. Its just all so different. And with so many different containers, IDEs and frame works out there its really hard to find simple concrete tutorials. Still I guess that's half the fun of a new job :)

Thanks for your reply
Andrew
 
For sure it will help others, but I think you can find some good tutorials with all steps like this

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top