Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

problem in Developing Struts small Apllication

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am useing Jdk1.5 and tomcat 5.5

==================== login.jsp=====================================

<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<html>
<head>
<title>Login Page</title>
</head>
<body>
<html:form action="/Login" focus="username">
<table align=center>
<tr>
<td>User Name :</td><td><input type=text name="username" /> </td>
</tr>
<tr>
<td>Password :</td><td><input type=password name="password" /> </td>
</tr>
<tr>
<td><input type=submit value="Login" /></td> <td><input type=reset value = "Reset" /></td>
</tr>
</html:form>
</body>
</html>

======================================================================


=====================LoginForm.java=======================================

package mnr;
import javax.servlet.http.*;
import org.apache.struts.action.*;
public class LoginForm extends ActionForm
{
public String username;
public String password;
public LoginForm()
{
super();
}
public void setUserName(String string)
{
this.username = string;
}
public String getUserName()
{
return this.username;
}
public void setPassWord(String string)
{
this.password = string;
}
public String getPassWord()
{
return this.password;
}
public ActionErrors validate(ActionMapping mapping,HttpServletRequest request)
{
ActionErrors errors = new ActionErrors();
if(username == null)
{
errors.add("username",new ActionMessage("errors.UserName.required"));
}
if(password == null)
{
errors.add("password",new ActionMessage("errors.PassWord.required"));
}
return errors;
}
}

===============================================================

======================LoginAction.java================================

package mnr;
import javax.servlet.http.*;
import org.apache.struts.action.*;
public class LoginAction extends Action
{
private static String SUCCESS = "success";
private static String FAILURE = "failure";
public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse reponse)
throws Exception
{
LoginForm lf = (LoginForm)form;
String username = lf.getUserName();
String password = lf.getPassWord();
if(username.equalsIgnoreCase(password))
return mapping.findForward(SUCCESS);
else
return mapping.findForward(FAILURE);
}
}

==========================================================================


========================struts-config.xml=====================================

<form-beans>
<form-bean name="LoginForm" type="mnr.LoginForm"/>

</form-beans>

<action-mappings>
<action input="/login.jsp"
name="LoginForm"
path="Login"
scope="request"
type="mnr.LoginAction">
<forward name="success" path="/success.jsp" />
<forward name="failure" path="/failure.jsp" />
</action>
</action-mappings>
=============================================================

Please Help me

With Regards


 
Ranch Hand
Posts: 1512
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, what seems to be the problem. Are you getting some sort of error. Your post says absolutely nothing!
 
She said she got a brazillian. I think owning people is wrong. That is how I learned ... tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic