Hi,
I'm quite new to struts, and I'm trying to make a simple example taken
from a website.
The first page show a formular, and when submited it is automatically
forwarded to an other page.
the problem is that when I submit, I get an absolute blank page, the
source is "<html><body></body></html>".
I checked Tomcat logs, and There is nothing wrong, the only thing is
that I'm sure is that the Action (in my case LoginAction) is not
performed because it produces a stdout output.
See attached files for details about code
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
<struts-config>
<form-beans>
<form-bean name="LoginForm" type="kdms.web.LoginForm" />
</form-beans>
<global-forwards>
<!-- forward to action mapping -->
<!--
<forward name="login" path="/WEB-INF/src/jsp/loginform.jsp" />
-->
<forward name="login" path="/Login.do" />
<forward name="welcome" path="/Welcome.do" />
</global-forwards>
<action-mappings>
<action
path="/Welcome"
forward="/WEB-INF/jsp/loginform.jsp"
unknown="true" />
<!-- -->
<action
path="/Login"
name="LoginForm"
scope="request"
type="kdms.web.LoginAction"
>
<forward
name="notconnected"
unknown="true"
path="/WEB-INF/jsp/loginform.jsp" />
<forward
name="connected"
path="/WEB-INF/jsp/connected.jsp" />
<!-- -->
</action>
</action-mappings>
</struts-config>
<%@ page language="java" import="java.util.*" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<html>
<head>
<title>Confirmation de connexion</title>
</head>
<body>
<h1 align="center">Confirmation de connexion</H1>
<div align="center">
</div>
</body>
</html>
<!--
<%@ page language="java" import="java.util.*" %>
-->
<%@ taglib uri="/WEB-INF/struts/struts-html.tld" prefix="html" %>
<html>
<head>
<title>Veuillez vous identifier</title>
</head>
<body>
<h1 align="center">Veuillez vous identifier</H1>
<div align="center">
<html:form action="Login.do" method="POST" focus="username">
Logon : <html:text property="username" /> <BR/>
Password : <html:password property="password" /> <BR/>
<html:submit property="submit" />
</html:form>
</div>
</body>
</html>
package kdms.web;
import javax.servlet.http.*;
import org.apache.struts.action.*;
public class LoginAction extends Action {
public ActionForward perform(
ActionMapping mapping,
ActionForm _form,
HttpServletRequest request,
HttpServletResponse response
) throws Exception
{
// On traite la requête cliente
LoginForm form = (LoginForm) _form;
System.out.println("Struts in action " + form.getUsername() + " - " +
form.getPassword());
// On redirige vers la vue adaptée
return mapping.findForward("connected");
}
}
package kdms.web;
import org.apache.struts.action.*;
public class LoginForm extends ActionForm {
private String m_username = "root";
private String m_password = "azerty";
public String getUsername() {
System.out.println("LoginForm.getUsername()");
return this.m_username;
}
public void setUsername(String username) {
System.out.println("LoginForm.setUsername("+username+")");
this.m_username = username;
}
public String getPassword() {
System.out.println("LoginForm.getPassword()");
return this.m_password;
}
public void setPassword(String password) {
System.out.println("LoginForm.setPassword("+password+")");
this.m_password = password;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]