the example code comes from the struts-logon application available from the struts website.
for session information you should use
Httpsession class for getting and setting session information. i.e.
HttpSession session = request.getSession(); session.setAttribute(Constants.USER_KEY, form);
HttpSession session = request.getSession(); LogonForm user = (LogonForm) session.getAttribute(Constants.USER_KEY);
also you have a typo in your struts-config.xml
scoope="request"
should read scope="request" this line is probably ignored from your struts-config.xml
From: Naohiro Kuroda <[EMAIL PROTECTED]> Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject: [Problem] Date: Mon, 04 Aug 2003 11:53:57 +0900
Dir sir,
I'm developing Web Application for Schedule Management in the company by Struts-1.1 now.
The contents are re-displayed after registering user information. But, if a new browser is opend, it will not those with a problem.
I think that session information remains, but i don't know how it should solve. please help me.
--------------------------------------------------------------------- -- Development environment ------------------------------------------ ---------------------------------------------------------------------
OS : Windows XP pro sp1 IDE : Eclipse2.1 JAVA : J2SDK 1.4.2 WEB-APP : Tomcat 4.1.24 Struts : jakarta-struts-1.1 Torque : torque-3.0
--------------------------------------------------------------------- -- struts-config.xml (Extract) -------------------------------------- ---------------------------------------------------------------------
<action path="/systemUserAdd" type="jp.co.eishindenki.admin.user.SystemUserAddInitAction" scope="request"> <forward name="success" path="/page/systemUserAdd.jsp"/> </action>
<action path="/userAdd" type="jp.co.eishindenki.admin.user.UserAddAction" name="userAddForm" scoope="request" input="systemUserAdd"> <forward name="success" redirect="true" path="/systemUserAdmin.do"/> </action>
--------------------------------------------------------------------- -- SystemUserAddInitAction ------------------------------------------ ---------------------------------------------------------------------
package --- omitted import --- omitted
public class SystemUserAddInitAction extends Action {
public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws Exception {
ServletContext context = getServlet().getServletContext();
if (context.getAttribute("jp.co.eishindenki.admin.user.groupList")
!= null) {
context.removeAttribute("jp.co.eishindenki.admin.user.groupList");
}
Criteria crit = new Criteria(); crit.addAscendingOrderByColumn(GroupInfoPeer.GROUP_ID); LinkedList groupList = new LinkedList(GroupInfoPeer.doSelect(crit));
context.setAttribute("jp.co.eishindenki.admin.user.groupList", groupList);
return mapping.findForward("success"); } }
--------------------------------------------------------------------- -- UserAddAction ---------------------------------------------------- ---------------------------------------------------------------------
package --- omitted import --- omitted
public class UserAddAction extends Action {
public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws Exception {
UserAddForm addForm = (UserAddForm) form;
UserInfo user = new UserInfo(); user.setUserName(addForm.getUserName()); user.setUserFurigana(addForm.getUserFurigana()); user.setLogonName(addForm.getLogonName()); user.setMailAddress(addForm.getMailAddress()); user.setTelNumber(addForm.getTelNumber()); user.setChargeIdOfQs(addForm.getChargeIdOfQs()); user.setExtNumber(addForm.getExtNumber()); user.setUrlAddress(addForm.getUrlAddress()); user.setAddress(addForm.getAddress()); user.setZipCode(addForm.getZipCode()); user.setPassword(addForm.getPassword()); user.setInitiationDate(addForm.getInitiationDate()); user.setMainGroup(addForm.getMainGroup()); user.save();
return mapping.findForward("success"); } }
--------------------------------------------------------------------- -- UserAddAction ---------------------------------------------------- ---------------------------------------------------------------------
package --- omitted import --- omitted
public class UserAddForm extends ValidatorForm {
private String userName; private String userFurigana; private String logonName; private String mailAddress; private String telNumber; private String ChargeIdOfQs; private int extNumber; private String urlAddress; private String address; private String zipCode; private String password; private Date initiationDate; private int mainGroup;
public void reset(ActionMapping mapping, HttpServletRequest req) { try { req.setCharacterEncoding("UTF-8"); } catch (Exception e) { e.printStackTrace(); }
/* getter & setter are omitted */
}
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE* http://join.msn.com/?page=features/junkmail
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]