• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error in creation of bean

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi friends I am consistently getting this error

javax.servlet.ServletException: Exception creating bean of class JavaSource.forms.registerform:

I have created a jsp file register.jsp as follow,

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="form" %>

<form:html>
<body>
<form:form action="/register.do">
User Name:<form:text property="username"/><br>
Enter Password:<form assword property="password1"/><br>
Re-Enter Password:<form assword property="password2"/><br>
<form:submit value="Register"/>
</form:form>
</body>
</form:html>

I am using Eclipse to create Dynamic web project.
For the above created register.jsp I have created a bean registerform.java
in forms folder under Javasource folder as..

package forms;

import org.apache.struts.action.*;
import org.apache.struts.action.ActionForm;

public class registerform extends ActionForm {
public String username=null;
public String password1=null;
public String password2=null;


public void setUsername(String aUsername)
{
username=aUsername;
}
public String getUsername()
{
return(username);
}

public void setPassword1(String aPassword1)
{
password1=aPassword1;
}
public String getPassword1()
{
return(password1);
}

public void setPassword2(String apassword2)
{
password2=apassword2;
}
public String getPassword2()
{
return(password2);
}
}

My struts-config.xml is as follows..

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-Apache Softaware Foundation 1.0//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">

<struts-config>
<form-beans>
<form-bean name="registerForm" type="JavaSource.forms.registerform"/>
</form-beans>

<action-mappings>
<action path="/register"
type="JavaSource.actions.registerAction"
name="registerForm"
input="/register.jsp" >
<forward name="success" path="/success.html"/>
<forward name="failure" path="/failure.html"/>
</action>
</action-mappings>

</struts-config>

Why the error javax.servlet.ServletException: Exception creating bean of class JavaSource.forms.registerform is coming ?
Can anybody help immediately..?
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Change

<form-bean name="registerForm" type="JavaSource.forms.registerform"/>

to

<form-bean name="registerForm" type="forms.registerform"/>

The source code you provoded indicates that the registerForm class is in package forms, not JavaSource.forms.

Also, just a note on style: Standard Java naming conventions dictate that a class name should start with an upper-case letter. You will want to change registerForm to RegisterForm.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic