struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Khalid K." <>
Subject RE: Struts - JSP does not store the user entered values when i click back (plz answer)
Date Sat, 07 Dec 2002 07:38:12 GMT
Can Someone answer this..i have the same problem....


-----Original Message-----
From: Almeida, Veeda [] 
Sent: Thursday, December 05, 2002 12:06 PM
To: 'Struts Users Mailing List'
Subject: Struts - JSP does not store the user entered values when i
click back

Good Morning,

When I load the jsp, go to next page and click on browser back button.
User entered values are not stored.

This happens everytime I open a new browser and launch the jsp page,
happens only for the first submit, does not happen otherwise.

Any ideas? Thanks in advance.

Below is the jsp and the action class :

<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <html:html
<title><bean:message key="login.title"/></title>
<body bgcolor="white">


<table border="1" size="100%">
            <bean:message key="login.title"/>
        <html:form action="/jsp/login" focus="username">
            <td><bean:message key="login.username"/></td>
            <td><html:text property="username" size="16"
            <td><bean:message key="login.password"/></td>
            <td><html:password property="password" size="16"
maxlength="16" redisplay="false"/></td>
            <td align="right"><html:submit property="submit"
            <td align="left"><html:reset/></td>

package com.mypackage;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionServlet;
import org.apache.struts.util.MessageResources;

public class loginAction extends Action {

	public ActionForward perform(
		ActionMapping mapping,
		ActionForm form,
		HttpServletRequest request,
		HttpServletResponse response)
		throws IOException, ServletException {

		// validate user input
		ActionErrors errors = new ActionErrors();

		String username = ((loginForm) form).getUsername();
		String password = ((loginForm) form).getPassword();

		User user = new User();

		if (!user.getFullName().equals(username)
			|| !user.getPassword().equals(password))

		// report any error back to origional form
		if (!errors.empty()) {
			saveErrors(request, errors);
			return (new ActionForward(mapping.getInput()));

		// save logged-in user in session
		HttpSession session = request.getSession();
		session.setAttribute(Constants.USER_KEY, user);

		// remove the obselete form bean
		if (mapping.getAttribute() != null) {
			if ("request".equals(mapping.getScope()))
		// forward control to the specified success uri
		return mapping.findForward("success");

} // end loginAction class

Veeda Almeida

This e-mail and any files transmitted with it are intended 
solely for the use of the addressee.  This e-mail may 
contain confidential and/or legally privileged information.  
Any review, transmission, disclosure, copying, or any action 
taken or not taken, by other than the intended recipient, in 
reliance on the information, is prohibited.  If you received 
this e-mail in error, notify the sender and delete this e-mail 
(and any accompanying material) from your computer and
network. In addition, please be advised that 21st Century 
Insurance Group reserves the right to monitor, access and 
review all messages, data and images transmitted through 
our electronic mail system. By using our e-mail system, you 
consent to this monitoring. 

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message