• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Why I get a blank page?

 
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I make a simple logon struts application.The index page is logon.jsp and it will go to secret.jsp if
the name and password is correct.But it will go to a blank page when user click the submit button unless
the "name" and "password" is correct.My struts-config.xml has any problem?I think mybe my LogonAction
is not correct but I don't know where.My directory is:"C:\tomcat\webapps\ROOT\struct".
//////////////////////////////logon.jsp//////////////////////////////////////////////
<html:form action="/logon" focus="name">
<tr>
<td>Name:</td>
<td><html:text property="name"/></td>
</tr>
<tr>
<td>Password:</td>
<td><html assword property="password"/></td>
</tr>
<tr><td>
<html:submit/><html:reset/>
</td></tr>
</html:form>
///////////////////////////LogonAction///////////////////////////////////////////////////
public class LogonAction extends Action{
public ActionForward execute(ActionMapping map,ActionForm form,HttpServletRequest req,HttpServletResponse resp)
throws IOException,ServletException{
String name=req.getParameter("name");
String pass=req.getParameter("password");
if(name!=null&&pass!=null&&name.equals("lyo")&&pass.equals("qijiashe")){
PrintWriter out=resp.getWriter();
out.println("Debug... ...");
HttpSession session=req.getSession();
session.setAttribute("logonsuccess","lyo");
return new ActionForward("/mainpage.jsp");
}else{
return new ActionForward("/mainpage.jsp");
}
}
}
////////////////////////////////////////struts-config.xml///////////////////////////////////////
<struts-config>
<form-beans>
<form-bean name="logonForm" type="struts.lyo.Logonform"/>
</form-beans>
<global-forwards>
<forward name="logout" path="/logout.do" />
<forward name="secret" path="/secret.jsp" />
</global-forwards>
<action-mappings>
<action path="/logon" name="logonForm" type="struts.lyo.LogonAction"/>
<action path="/logout" type="struts.lyo.LogoffAction"/>
</action-mappings>
</struts-config>
///////////////////////////////////////Logonform.java/////////////////////////////////
public class Logonform extends ActionForm{
private String name;
private String password;
public void setName(String name){
this.name=name;
}
public String getName(){
return this.name;
}
public void setPassword(String password){
this.password=password;
}
public String getPassword(){
return this.password;
}
}
Any error?help ... :roll:
 
Yashnoo lyo
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem solved!I change the "execute" method to "perform" method in my "LogonAction".It worked
as I expected.But I can't really know Why.I use struts1.0.Does struts1.1 has the "perform" method only?
I think "struts1.0" use the "execute" method in Action. Anyone can give me some idea?
:roll:
 
You had your fun. Now it's time to go to jail. Thanks for your help tiny ad.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic