Solved

Pass Parameter from Action class to JSP using Struts

Posted on 2006-06-29
2
567 Views
Last Modified: 2009-12-16
hi,

I get few parameter from JSP page, fwd to Action class which writes those parameter into DB after auto-generating ID.
DB -table
ID (auto generate), Name, Question, Email.

what I'm trying to do is afer action class writes to DB. I wanna get that generated ID and fwd to JSP which display fancy msg and #ID.

Action Class.
...
...
ResultSet rs = st.executeQuery("select max(id) as ID from Test123");
            rs.next();
            int rowid=rs.getInt("ID");
          status ="pass";
..
return (mapping.findForward(status));
..

thx,
PH
0
Comment
Question by:princehyderabad
2 Comments
 
LVL 16

Accepted Solution

by:
suprapto45 earned 100 total points
ID: 17015344
Why don't you just send the parameter from request?

request.setAttribute("id", Integer.toString(rowid));

Then you can simply access the request object from your JSP

David
0
 
LVL 35

Assisted Solution

by:girionis
girionis earned 25 total points
ID: 17015952
... or put it in the session

HttpSession session = req.getSession(true);
session.setAttribute("id", <your id>);
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to implement Singleton Design Pattern in Java.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now