package com.is.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.is.form.LoginForm;
public class LoginAction extends Action
{
private static final long serialVersionUID = 1L;
public ActionForward execute
(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
// this line is here for when the
input page is upload-utf8.jsp,
// it sets the correct character
encoding for the response
String encoding = request.getCharacterEncoding();
if ((encoding != null) &&
(encoding.equalsIgnoreCase("GB2312")))
{
response.setContentType
("text/html; charset=GB2312");
} else {
response.setContentType
("text/html; charset=GBK");
}
try {
if (form instanceof LoginForm)
{
LoginForm theForm = (LoginForm) form;
if(theForm.getUsername().equals("user") &&
theForm.getPassword().equals("123456"))
{
return new ActionForward("/welcome.do?type=true");
}
else {
return new ActionForward("/welcome.do?type=false");
}
}
} catch (Exception e)
{
}
// this shouldn't happen in this example
return null;
}
} |