Question:
How you will save the data across different pages for a particular client request using Struts?
Answer:
One simple and general way is by using session Object. In specific, we can pass this by using request Object as well.
Submitted by Sagar GV ([email protected])
_________
Create an appropriate instance of ActionForm that is form bean and store that form bean in session scope. So that it is available to all the pages that for a part of the request.
request.getSession() session.setAttribute()
Submitted by Raghu Udupa ([email protected]) Source: CoolInterview.com
Setting scope as session can be done with <action > tags in Struts-Config.xml
<action path="/login" name="loginForm" scope="session" parameter="method" type="com.sss.core.LoginAction" input="/index.jsp" /> Source: CoolInterview.com
Answered by: Balaji.S | Date: 4/17/2009
| Contact Balaji.S
We have different levels of storage objects(scopes) like
Page Request Session Application Context like this....we can store the data in any scope like if you want to keep the data in page level u can set the data to page, else you can set to request like this.
Source: CoolInterview.com
Answered by: Venu | Date: 12/22/2009
| Contact Venu
we define scope inside action tag in struts.config xml if session is scope than the request processor set data to session scope.but always prefer request scope for good programming. Source: CoolInterview.com
Answered by: anil mishra | Date: 1/27/2010
| Contact anil mishra
Class.forName("oracle.jdbc.driver.OracleDriver"); Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","system","navroon"); PreparedStatement stmt=con.prepareStatement("select * from check11"); ResultSet rs=stmt.executeQuery(); String username=lf.getUSERNAME(); String password=lf.getPASSWORD(); System.out.println(username+"######"+password); while(rs.next()){ System.out.println(rs.getString(1)+"&&&&&&&&"+rs.getString(2)); if(username.equalsIgnoreCase(rs.getString(1)) && password.equalsIgnoreCase(rs.getString(2))){ return mapping.findForward("purchase"); } } return mapping.findForward("order"); Source: CoolInterview.com
Answered by: fourns | Date: 9/3/2010
| Contact fourns
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|