Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with form submission!!

 
dinesh prasad
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.. I have a problem
I'm using the following files to do some basic input checking from a form:
register.htm gathers input and submits to process.jsp
process.jsp calls FormBean.class which does some basic error checking, control goes back to process.jsp
[IF] FormBean's validate method() comes back valid, the user is directed to success jsp and his information is copied to a database handler bean
[ELSE]
redirect user to retry.jsp
____________________________________
I get the following error message (I get the same thing deploying under websphere)
An error occurred at line: 10 in the JSP file: /process.jsp
Generated servlet error:
C:\Sun\studio5_se\appserver7\domains\domain1\server1\generated\jsp\j2ee-modules\Forms\_jasper\_process_jsp.java:76: Class _jasper.FormBean not found.
FormBean formHandler = null;
^

________________________________________________
FormBean.class
import java.util.*;
public class FormBean {

private String email;
private String userName;
private String password1;
private String password2;
private String displayname;
private Hashtable errors;
public boolean validate() {
boolean allOk=true;

if (email.equals("") || (email.indexOf('@') == -1)) {
errors.put("email","Please enter a valid email address");
email="";
allOk=false;
}
if (userName.equals("")) {
errors.put("userName","Please enter a username");
userName="";
allOk=false;
}
if (password1.equals("")) {
errors.put("password1","Please enter a valid password");
password1="";
allOk=false;
}
if (!password1.equals("") && (password2.equals("") || !password1.equals(password2))) {
errors.put("password2","Please confirm your password");
password2="";
allOk=false;
}
if (displayname.equals("") ) {
errors.put("displayname", "Please enter a display name");
displayname="";
allOk=false;
}


return allOk;
}

public FormBean() {

email="";
password1="";
password2="";
displayname="";

errors = new Hashtable();
}

public String getEmail() {
return email;
}

public String getPassword1() {
return password1;
}

public String getPassword2() {
return password2;
}
public String displayname() {
return displayname;
}


public void setEmail(String eml) {
email=eml;
}

public void setPassword1(String p1) {
password1=p1;
}
public void setPassword2(String p2) {
password2=p2;
}
public void setdisplayname(String dp) {
displayname=dp;
}


}
_________________________________________________
register.htm
<html>
<body>
<form action="process.jsp" method=post>
<center>
<table cellpadding=4 cellspacing=2 border=0>
<th bgcolor="#CCCCFF" colspan=2>
<font size=5>Pollmeister.com - Tell us who you are!</font>
<br>
<font size=1><sup>*</sup> Required Fields</font>
</th>
<tr bgcolor="#c8d8f8">
<td valign=top>
<b>Your email address<sup>*</sup></b>
<br>
<input type="text" name="email" value="" size=60 maxlength=20></td>

<tr bgcolor="#c8d8f8">
<td valign=top>
<b>Password<sup>*</sup></b>
<br>
<input type="password" name="password1" size=10 value="" maxlength=10></td>
<td valign=top>
<b>Confirm Password<sup>*</sup></b>
<br>
<input type="password" name="password2" size=10 value="" maxlength=10></td>
<br>
</tr>
<tr>
<tr bgcolor="#c8d8f8">
<td valign=top>
<b>Desired Display name (This is what will be seen by other users)<sup>*</sup></b>
<br>
<input type="text" name="displayname" size=12 value="" maxlength=12></td>
<br>
</tr>
<tr bgcolor="#c8d8f8">
<td align=center colspan=2>
<input type="submit" value="Submit"> <input type="reset" value="Reset">
</td>
</tr>
</table>
</center>
</form>
</body>
</html>
_____________________________________________
process.jsp
<%@ page import="java.util.*" %>
<%!
ResourceBundle bundle =null;
public void jspInit() {
bundle = ResourceBundle.getBundle("forms");
}
%>
<jsp:useBean id="formHandler" class="FormBean" scope="request">
<jsp:setProperty name="formHandler" property="*"/>
</jsp:useBean>
<% if (formHandler.validate()) {
%>
<%--
<jsp:forward page="<%=bundle.getString(\"process.success\")%>"/>
--%>
<jsp:forward page="/DBHandler"/>
<%
} else {
%>
<jsp:forward page="<%=bundle.getString(\"process.retry\")%>"/>
<%
}
%>
_________________________________________________
I've deployed this application as an EAR file under websphere as well as Sun App server. Neither work. Here is the directory structure:
/project/ <- html and jsp files
/project/WEB-INF/classes <- bean
/project/WEB-INF/ <- web.xml
I got the source code from this tutorial:
http://www.javaworld.com/javaworld/jw-03-2000/jw-0331-ssj-forms-p4.html

Thanks for any help!!!

Dinesh the one
 
kavitha rama
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
If you are using any package, give the fully qualified classname
ex: <jsp:useBean id="formHandler"
class="org.xxx.iccbeans.SubmissionHandler"
scope="request"
>
Check whether class files are being generated and are in right place WEB-INF/classes/package/*.class
Problem is it is not finding class file. So, check for that
 
dinesh prasad
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kavitha,
I tried what you said, but I'm still getting the same thing. I get the following error message:
_process_jsp.java [76:1] package foo does not exist
foo.FormBean formHandler = null;
^
I'm also getting an invalid package declaration on my java bean, though it compiles.
I've placed my classes under foo/WEB-INF/classes
I tried putting the jsp in the foo directory and also WEB-Inf. I added c:\foo to my classpath. I tried what you said when calling the bean:
<jsp:useBean id="formHandler" class="foo.FormBean" scope="request">
<jsp:setProperty name="formHandler" property="*"/>
</jsp:useBean>
Thanks for any help,
Dinesh
[ June 26, 2003: Message edited by: dinesh prasad ]
 
Vivek Mongolu
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Dinesh
the bean classes should go into the WEB-INF folder
so if your class name is FormBean and its under foo package then
you would place it in
WEB-INF/classes/foo/FormBean
and in your jsp page import that package
<%@ page import="foo.*" %>
hope this helps
Vivek
 
dinesh prasad
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help Vivek that seems to work. Where should I put my JSPs at? I get this error message now.
foo/process.jsp [-1:-1] java.io.FileNotFoundException: /foo/process.jsp
 
Vivek Mongolu
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the preferred way is to follow a directory structure. On Tomcat you will place the entire project under the webapps directory.
lets say the project name is proj.
this proj should have a WEB-INF folder, which in turn contains classes and lib folder. you will place your packages under classes folder and any required jar files in lib folder.
the jsp's / servlets go directly under the proj folder.
proj/jsp files - servlets
proj/WEB-INF/classes/your packages
proj/WEB-INF/lib/ your project reqd jar files
what server are you using??
hope this clears everything
Vivek
 
dinesh prasad
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.. Now, I'm getting another error message about the package.
An error occurred at line: 10 in the JSP file: /process.jsp
Generated servlet error:
Class _jasper.FormBean not found.
FormBean formHandler = null;
^
Here is the directory structure:
examples2/ <- jsp/html files
examples2/WEB-INF/ <- web.xml
examples2/WEB-INF/classes/foo <- FormBean.class
I'm using the sun one studio developer, it has a bundled application server. It should be similar to tomcat right? i AM finally getting the first html page to load up. It is when I submit the form to process.jsp that this error occurs. Thanks again!
Any more suggestions?
Dinesh
[ June 27, 2003: Message edited by: dinesh prasad ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!