Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
|
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 14th, 2006, 06:17 AM
Authorized User
 
Join Date: Aug 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Calverstine Send a message via MSN to Calverstine
Default java bean file not found / cannot resolve symbol r

:) hi everybody,
--------------------------------------------------------------------------
Brief intro.
I am a fresh new comer to devX forum, and yesterday I installed tomcat and wanted to try the power of java bean by implementing the code under JSP web developement platform. MY code is attached within the .zip file. This is just a simple program to get user's data username, password, and gender into the bean file, then when user click next the data value stored will be displayed on that particular page.
--------------------------------------------------------------------------
My key point of error:

<jsp:useBean id="user" class="registerUser" scope="session"/>

The error message are:
org.apache.jasper.JasperException: Unable to compile class for JSP
--------------------------------------------------------------------------
An error occurred at line: 1 in the jsp file: /login/action.jsp

Generated servlet error:
[javac] Compiling 1 source file

C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\login\action_jsp.j ava:42: cannot resolve symbol
symbol : class registerUser
location: class org.apache.jsp.action_jsp
registerUser user = null;
--------------------------------------------------------------------------
My platform for running JSP are :

Tomcat - C:\Program Files\Apache Group\Tomcat 4.1
java - C:\j2sdk1.4.2_10

My system classpath are:
C:\Program Files\Java\j2re1.4.2_10\lib\ext\QTJava.zip;C:\Prog ram Files\mysql\mysql-connector-java.jar;C:\j2sdk1.4.2_10\jre\lib\ext\mysql-connector-java-3.0.17-ga-bin.jar;C:\Program Files\Apache Group\Tomcat 4.1\webapps\ROOT\WEB-INF\classes;c:\java;

my java file compilation folder was located at C:\java
--------------------------------------------------------------------------
What happened to this code?? Can any kind helper assist to explain the root cause of this error, and if possible guide me throught this error??


-------------------------------registeruser.jsp-----------------------
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<head>
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {
    font-family: Geneva, Arial, Helvetica, sans-serif;
    font-weight: bold;
    color: #FFFFFF;
}
.style3 {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10px;
}
-->
</style>
</head>

<body>

<form name="form1" method="post" action="action.jsp">

<input type="hidden" name="authenticate" value="run">

  <table width="605" border="0" align="center" bgcolor="#666666">
    <tr>
      <td colspan="2"><div align="center">
          <h3 class="style1">Register new user </h3>

      </div></td>
    </tr>
    <tr>
      <td class="style1">user ID:</td>
      <td><div align="left">
        <input name="username" type="text" id="username">
      </div></td>
    </tr>
    <tr>
      <td class="style1">password:</td>
      <td><div align="left">
        <input name="password" type="text" id="password">
      </div></td>
    </tr>
    <tr>
      <td class="style1"> gender </td>
      <td><input name="gender" type="radio" value="male">
        <strong class="style3">male</strong> <input name="gender" type="radio" value="female">
        <span class="style3">female </span></td>
    </tr>
    <tr>
      <td colspan="2" class="style1"></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><div align="left">
        <input type="submit" name="Submit" value="Submit">
      </div></td>
    </tr>
  </table>
</form>
</body>
</html>
-------------------------------registeruser.jsp----------------------
public class registerUser
{
    String username="";
    String password="";
    String gender="";

    public void setUsername(String username)
    {
        this.username=username;
    }
    public void setPassword(String password)
    {
        this.password=password;
    }
    public void setGender(String gender)
    {
        this.gender=gender;
    }
    public String getUsername()
    {
        return username;
    }
    public String getPassword()
    {
        return password;
    }
    public String getGender() {
        return gender;
    }

}
-------------------------------action.jsp----------------------------
<jsp:useBean id="user" class="registerUser" scope="session"/>
<jsp:setProperty name="user" property="*"/>
<HTML>
<BODY>
<A HREF="NextPage.jsp">Continue</A>
</BODY>
</HTML>
-----------------------------nextpage.jsp----------------------------
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<jsp:useBean id="user" class="registerUser" scope="session"/>
<jsp:setProperty name="user" property="*"/>
<HTML>
<BODY>
Username: <%= user.getUsername() %><br>
Password: <%= user.getPassword() %><br>
Gender: <%= user.getGender() %><br>
</BODY>
</HTML>
:)

 
Old July 1st, 2006, 07:53 PM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 198
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Did you compile registerUser.java into registerUser.class and put it in your classpath? By the way, I would suggest capitalizing the first letter of your classnames. E.g. name your bean source RegisterUser, not registerUser.java. This is convention when developing Java. Also, I would recommend putting your beans into a package.

Jon Emerson
http://www.jonemerson.net/
 
Old July 2nd, 2006, 07:04 AM
Registered User
 
Join Date: Dec 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

if u r using jdk1.4 or above, make a default constructor for the bean class.. eg.

public class RegisterUser
{
public RegisterUser(){}



-- Your set and get methods here
--
--

}

 
Old July 2nd, 2006, 09:17 PM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 198
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Rajeev,

A parameterless constructor is automatically created if no other constructors are defined in a class. I don't believe there have been any changes in this area since Java 1.0. If someone has any history to share, let me know.

Jon Emerson
http://slashdot.org/~panaceaa
 
Old July 3rd, 2006, 05:38 AM
Authorized User
 
Join Date: Jun 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

It seems you missed importing registerUser
 bean in the action.jsp.

prasanth.c





Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot resolve object, cannot find java file!!help Calverstine Apache Tomcat 3 May 22nd, 2006 03:02 PM
cannot resolve symbol (struts) tomeksupergosc J2EE 2 November 23rd, 2004 01:19 PM
Error-cannot resolve symbol Rusk JSP Basics 1 February 18th, 2004 09:20 AM
cannot resolve symbol problem ioda006 JSP Basics 2 July 28th, 2003 06:04 AM
Error: Cannot resolve symbol "Beginning JSP" amcp2002 Wrox Book Feedback 2 July 22nd, 2003 03:30 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.