Jsp-servlet-bean problem

Please help!
I have a servlet controller, a javabean for the data and a jsp for the view.
I cannot get the jsp using
<jsp:useBean id="pList" class="bbs.PostListCommand" scope="request" />
to access the bean data
However, when I access the bean in this way
<%@ page import="bbs.PostListCommand" %>
// html
<% bbs.PostListCommand postList = null;
synchronized(session){
     postList = (bbs.PostListCommand) session.getAttribute("PostListCommand");
     if (postList == null){ %>
          <H1>Nothing in request scope to retrieve ....</H1>
          <P>
<%     }
     else{  %>
          <TABLE border="1">
// etc
� it works
Does anyone know why the <jsp:useBean> tag does not find the bean
I have installed tomcat 4.18 and set the environmental variables etc.
Directory structure is
E:\Tomcat41\webapps\examples\WEB-INF\jsp          for jsp�s
E:\Tomcat41\webapps\examples\WEB-INF\classes\bbs     for bean and servlets
Thanks in advance for any help.
Chris

GrayMan - Thanks for your help.
Let me explain my problem in more detail ...
Background:
I have some servlet experience, but I am new to jsp - so sorry if this seems trivial to you ...
I have a book called bitter java by bruce tate from manning.com . I am trying to get the chapter 3 examples to work
There are three files
PostListCommand          the bean
PostListController     the servlet
PostListResults          jsp
And a new test file � PostListResults version 2 with scriptlet code to access the bean.
There are a couple of typos in the downloaded source files, but nothing that causes the main problem of not being able to access the bean data.
Program flow
Servlet instantiates new bean
Bean � gets data from db
Servlet passes bean to jsp with a forward
Jsp outputs data
I have put the files in the directories �
E:\Tomcat41\webapps\examples\WEB-INF\jsp          for jsp�s
E:\Tomcat41\webapps\examples\WEB-INF\classes\bbs     for bean and servlets
The complete source code for each file is given below.
1 I have checked the db access � that�s ok
2 I have also checked reading the bean data back in from the request scope and printing out the results from within the servlet.- ok
3 I can access the data through a scriptlet (PostListResults version 2), but not with the original PostListResults which uses <jsp:useBean>
thanks in advance, chris
PostListController.java
package bbs;
// Imports
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
// Import for commands used by this class
import bbs.PostListCommand;
public class PostListController
extends javax.servlet.http.HttpServlet
implements Serializable {
* DoGet
* Pass get requests through to PerformTask
public void doGet(
HttpServletRequest request,
HttpServletResponse response)
throws javax.servlet.ServletException, java.io.IOException {
performTask(request, response);
public void performTask(
HttpServletRequest request,
HttpServletResponse response) {
try {
PostListCommand postList = (bbs.PostListCommand) java.beans.Beans.instantiate(getClass().getClassLoader(),"bbs.PostListCommand");
postList.initialize();
postList.execute();
request.setAttribute("PostListCommand", postList);
ServletContext sc = this.getServletContext();
RequestDispatcher rd =
sc.getRequestDispatcher("/jsp/PostListResults.jsp");
rd.forward(request, response);
} catch (Throwable theException) {
theException.printStackTrace();
PostListCommand.java
package bbs;
import java.io.*;
import java.sql.*;
//import COM.ibm.db2.jdbc.*;
import java.util.*;
* Insert the type's description here.
* Creation date: (07/17/2001 5:07:55 PM)
* @author: Administrator
public class PostListCommand {
// Field indexes for command properties     
private static final int SUBJECT_COLUMN = 1;
private static final int AUTHOR_COLUMN = 2;
private static final int BOARD_COLUMN = 3;
protected Vector author = new Vector();
protected Vector subject = new Vector();
protected Vector board = new Vector();
// SQL result set
protected ResultSet result;
protected Connection connection = null;
* execute
* This is the work horse method for the command.
* It will execute the query and get the result set.
public void execute()
throws
java.lang.Exception,
java.io.IOException {
try {
// retrieve data from the database
Statement statement = connection.createStatement();
result =
statement.executeQuery("SELECT subject, author, board from posts");
while (result.next()) {
subject.addElement(result.getString(SUBJECT_COLUMN));
author.addElement(result.getString(AUTHOR_COLUMN));
board.addElement(result.getString(BOARD_COLUMN));
result.close();
statement.close();
} catch (Throwable theException) {
theException.printStackTrace();
* getAuthor
* This method will get the author property.
* Since the SQL statement returns a result set,
* we will index the result.
public String getAuthor(int index)
throws
java.lang.IndexOutOfBoundsException,
java.lang.ArrayIndexOutOfBoundsException {
return (String) author.elementAt(index);
* getBoard
* This method will get the board property.
* Since the SQL statement returns a result set,
* we will index the result.
public String getBoard(int index)
throws
java.lang.IndexOutOfBoundsException,
java.lang.ArrayIndexOutOfBoundsException {
return (String) board.elementAt(index);
* getSubject
* This method will get the subject property.
* Since the SQL statement returns a result set,
* we will index the result.
public String getSubject(int index)
throws
java.lang.IndexOutOfBoundsException,
java.lang.ArrayIndexOutOfBoundsException {
return (String) subject.elementAt(index);
* initialize
* This method will connect to the database.
public void initialize()
throws java.io.IOException {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
// URL is jdbc:db2:dbname
String url = "jdbc:db2:board";
// URL is jdbc:odbc:bitter3board
String url = "jdbc:odbc:bitter3board";
// connect with default id/password
connection = DriverManager.getConnection(url);
} catch (Throwable theException) {
theException.printStackTrace();
* Insert the method's description here.
* Creation date: (07/17/2001 11:38:44 PM)
* @return int
* @exception java.lang.IndexOutOfBoundsException The exception description.
public int getSize() {
return author.size();
PostListResults.jsp
<HTML>
<HEAD>
<TITLE>Message Board Posts</TITLE>
</HEAD>
<BODY BGCOLOR=#C0C0C0>
<H1>All Messages</H1>
<P>
<jsp:useBean id="postList" class="bbs.PostListCommand" scope="request"></jsp:useBean>
<TABLE border="1">
<TR>
<TD>Subject</TD>
<TD>Author</TD>
<TD>Board</TD>
</TR>
<% for (int i=0; i < postList.getSize(); _i++) { %>
<TR> <TD><%=postList.getSubject(_i) %></TD>
<TD><%=postList.getAuthor(_i) %></TD>
<TD><%=postList.getBoard(_i) %></TD>
</TR>
<% } %>
</TABLE>
<P>
</BODY>
</HTML>
PostListResults.jsp version 2 � with scriplet code instead of useBean
<HTML>
<%@ page import="bbs.PostListCommand" %>
<!-- This file was generated by the chris -->
<HEAD>
<TITLE>Message Board Posts</TITLE>
</HEAD>
<BODY BGCOLOR=#C0C0C0>
<% bbs.PostListCommand postList = null;
synchronized(request){
     postList = (bbs.PostListCommand) request.getAttribute("PostListCommand");
     if (postList == null){ %>
          <H1>Nothing in request scope to retrieve ....</H1>
          <P>
<%     }
     else{  %>
          <TABLE border="1">
          <TR>
          <TD>Subject</TD>
          <TD>Author</TD>
          <TD>Board</TD>
          </TR>
     <% for (int i=0; i < postList.getSize(); _i++) { %>
               <TR> <TD><%=postList.getSubject(_i) %></TD>
          <TD><%=postList.getAuthor(_i) %></TD>
          <TD><%=postList.getBoard(_i) %></TD>
          </TR>
     <% } %>
          </TABLE>
<%     }
}%>
<P>
goodnight
</BODY>
</HTML>

Similar Messages

  • JSP- Servlet-- Bean-- JSP how to implement

    I have problem.
    My JSP will take a emplyee id .
    Now I want to show all the values regarding that employee in a JSP(JSP form) from the DB(Oracle).
    So Iam planning like
    JSP-->Servlet-->Bean-->JSP
    So my doubts are.
    1. Is it correct approach
    2.If it is correct then which part of the flow connects to DB and stores the value before putting to JSP.
    Iam using Tomcat 4.31
    Plz help me

    I have problem.
    My JSP will take a emplyee id .
    Now I want to show all the values regarding that
    employee in a JSP(JSP form) from the DB(Oracle).
    So Iam planning like
    JSP-->Servlet-->Bean-->JSP
    So my doubts are.
    1. Is it correct approach
    2.If it is correct then which part of the flow
    connects to DB and stores the value before putting to
    JSP.
    Iam using Tomcat 4.31
    Plz help meHI
    What you are probably proposing is an MVC design pattern. I wonder if u have heard of the struts framework. Sruts uses MVC design pattern wherein the servlet u are talking about acts as a controller(C) and the bean acts as the model(M) .The JSPs present the view(V). Hence the name MVC.
    Your approach is right. First get the employee ID from the jsp and get the corresponding data from database(This logic u implement in the servlet). Then save the fetched data in a bean so that the result jsp can fetch data from it.
    Now this is not a strict MVC approach.
    Learn more about struts. It presents a much more cleaner solution.

  • Sample jsp servlet bean (MVC) code

    We want to look into the JSP/Servlet/Bean area for our next project. We wish to understand the technology and as such want to hand build simple applications, and as such do not want to use JDeveloper just yet.
    We have searched and searched for suitable material but cannot anywhere find a sample application that :
    A. Lists contents of a databse table
    B. Each item in trhe list is a link to a page that allows that item, to be edited.
    C. A new item can be added.
    D. Uses the MVC model of JSP/Servlet and bean (preferably with no custom tags)
    There are examples that are too simplistic and do not cover the whole picture. Having spent over 100 GBP on books lately, only to be disappointed with the examples provided, we need to see some sample code.
    The samples provided by Oracle are too simplistic. They should really have provided ones built around the EMP and DEPT tables.
    Anyone know where we can get hold of this sample code.

    At the risk of sounding really dumb the examples are just too complex. There does not appear to be anywhere on the web where I can find a simple JSP/servlet/bean example of the type I described. There is enouigh material describing each individual component, but what I need is an example to cement the ideas, but the ones suggested are too much for a newbie. Even the much vaunted Pet Store thingy causes my eyes to glaze over.
    I dont expect anyone to have written something with my exact requirements, but surely to goodness there must be something that:
    1. On entry presents a search form on a table (e.g. EMP)
    2. On submission list all rows in EMp matchiung the criteria.
    3. The user can either click the link 'Edit' which opens up a form dispalying the row allowing the user to edit and save the changes, or click the 'New' button to show a blank form to create a new EMP.
    All this via a Controller servlet, with the database logic handled by a java bean, and all the presentation done via JSP.
    To me this is the most obvious and instructive example of this technology, but after days of trawling the web, and looking through a number of books, I cannot find such a thing.
    CGI with Perl DBI/DBD was a breeze to work with compared to this stuff ..... maybe ASP with SQL/Server would be a more fruitful use of time.

  • Servlet Beans problem

    Hi all,
    i am new to servlet and Beans.I am facing a problem currently i have designed a JSP page for adding user information after submitting the information i am calling a servlet from that JSP page to submitt data to the data base which is MYsql,i have made a bean namely DatabaseConnection to connect to the database.,the submission of data is working fine.
    the problem i am facing is in displaying the data from the database.again we have made a servlet to fetch data from the database we are using a Bean to set the data in to beans ,currently we are passing the RecordSet as an argument to the SetData function in the bean which is setting the data in the bean variables. At the end of the servlet i,e after setting the data in the beans we are forwarind the controll to the Display.JSP form using request dispatcher method .In the Display form we are using <use:Jsp beans> tage and <get property tag> but unable to show any data it's showing null there.
    i need help if some body guide me to the right track...
    Thanks in advance
    umesh

    awasss..
    Y dont u send ur jsp which used jsp:use bean tag? Hope u are setting the bean correctly in the request or seesion scope from the servlet before commin to jsp.. :)
    regards
    Shanu

  • Jsp / Servlet / bean / upload

    Hello,
    I use a jsp to enter several fields. These fields are sent to a servlet by using a bean (recorded in the current session). Until now there is no problem. The servlet receives all information. Now I must also send 5 files which must be stored on the server. I have thus to add in my jsp 5 file fields.
    My question :
    Is it possible to integrate the FileUpload package for uploader my files without anything to change in my code (by using of a bean to exchange the data between my jsp and my servlet). ??
    In other words, it is possible to use my bean to also transport files. ??
    Tank u for u help

    Yes it is possible..
    download cos.jar from www.oreily.com for file upload..
    it will read dat from the form as two parts ..
    parameter part and file part..
    and you can implement it throgh a servlet easily..
    for more follow oreily JSP/servlets Cookbook

  • Change Drop Down from Other JSP/Servlet/Bean

    I am wanting to have a select box populate from a database query based on the information pulled from another select box as the user chooses it (ie a user chooses a state and the city choices populate or something like that). I am using JSP, Servlets and Beans. Seems that I need to us JSF, but I was wondering if there is another way or better way.
    Thanks for the thoughts.

    user12081556 wrote:
    I meant to put in my question above, aren't jsf tags just imbedded in some jsp/html code?Not jsp code no. I don't know whether it's possible to use jsf and jsp together, but I wouldn't try.
    While JSP has evolved over time from Html and Java code mixed together to standard tags responsible mostly for displaying the data, it's still an old "hack" that compiles jsp pages into servlets.
    JSF at least alleviates some of those problems and works nicely with proper xhtml formatted views too (and there's facelets etc. etc. etc.).
    Granted, if you're shown some jsp tags and jsf tags, you might not appreciate the difference in the technologies.

  • Jsp,servlet,bean question,please help

    The Tomcat Web server set up like this.......
    The directory structure is
    e:/sampleapp/WEB-INF/classes
    /lib
    And the web.xml is in the WEB-INF for the use of ay potential servlet.
    The basic understanding is that all the .java files go into the WEB-INF directory and the .class files go into the classes directory.
    All the .jsp files go into the sampleapp directory.Till here is correct I feel.
    Now for my qustion......
    I plan to use jsp,servlet and beans for a potential web application...,where do all these files go?,just the same as above or is there a difference.
    Hope that I have given a reasonable explaination to my question.
    Thanks for any replies
    AS

    All of your compiled servlet and java bean (java
    classes in general) will be placed into the following
    directory (under a directory structure matching the
    java package they are in):
    e:/sampleapp/WEB-INF/classesAll of your .jar files that are used as libraries (not
    your .jar files for applets):
    e:/sampleapp/WEB-INF/libAll of the rest of your JSP files, javascript files,
    HTML files, JAR files, images files, etc. will go into
    the following directory:
    e:/sampleappYou must make sure you put your sampleapp directory
    where tomcat can load it. Or use the admin tool to
    load it. If you make a .WAR file with a corresponding
    web.xml file in it, it will simplify loading it into
    tomcat. It also will help you do your servlet
    mappings, etc. I hope this helps.Thanks for your timely response.To add to it,let me tell you.
    The <b>bean</b> files are put into a package right,so they should be put into the WEB-INF/classes/<package name>
    What about The <b> servlet </b> files...... they are just put into the WEB-INF/classes/ directory????
    Kindly let me know.
    Thanks
    AS

  • JSP Accesing Bean Problem

    I need a help in this jsp and bean Please provide the solution
              This is the bean
              import java.text.*;
              import java.util.*;
              import java.io.Serializable;
              public class DateBean implements Serializable {
              public DateBean() {}
              SimpleDateFormat sdf;
              public void setFormat(String format) {
              sdf = new SimpleDateFormat(format);
              public String getCurrentTime() {
              return sdf.format(new Date());
              This is the date.jsp
              <html>
              <head>
              <title>A JSP that sets a property</title>
              </head>
              <body>
              The current time and date, in several formats, courtesy
              a bean:<p>
              <!-- begin example -->
              <jsp:useBean
              id="date"
              class="DateBean"/>
              <ul>
              <jsp:setProperty name="date" property="format"
              value="EEEE, MMMM dd yyyy 'at' hh:mm"/>
              <li><jsp:getProperty name="date" property="currentTime"/>
              <jsp:setProperty name="date" property="format"
              value="hh:mm:ss MM/dd/yy"/>
              <li><jsp:getProperty name="date" property="currentTime"/>
              <jsp:setProperty name="date" property="format"
              value="yyyyy.MMMMM.dd GGG hh:mm aaa"/>
              <li><jsp:getProperty name="date" property="currentTime"/>
              </ul>
              <!-- end example -->
              </body>
              </html>
              AND THIS is the compilation error
              Error: [jspc]: 1 file(s) failed:
              /dates.jsp
              [Compilation errors : ]
              E:\DateBean\__dates.java:134: cannot resolve symbol
              symbol : class DateBean
              location: class jsp_servlet.__dates
              DateBean date = null; //[ /dates.jsp; Line: 13]
              ^
              E:\DateBean\__dates.java:135: cannot resolve symbol
              symbol : class DateBean
              location: class jsp_servlet.__dates
              date = (DateBean)pageContext.getAttribute("date"); //[ /dates.jsp; Line: 13]
              ^
              E:\DateBean\__dates.java:138: cannot resolve symbol
              symbol : class DateBean
              location: class jsp_servlet.__dates
              date = (DateBean)pageContext.getAttribute("date"); //[ /dates.jsp; Line: 13]
              ^
              E:\DateBean\__dates.java:140: cannot resolve symbol
              symbol : class DateBean
              location: class jsp_servlet.__dates
              date = new DateBean(); //[ /dates.jsp; Line: 13]
              ^
              4 errors
                   at weblogic.jspc.doCompile(Ljava.lang.String;Ljava.util.List;Lweblogic.utils.Getopt2;ZLjava.lang.String;)V(jspc.java:839)
                   at weblogic.jspc.runJspc(Lweblogic.utils.classloaders.GenericClassLoader;Ljava.io.File;Ljava.util.Map;Z)V(jspc.java:632)
                   at weblogic.jspc.runBodyInternal()V(jspc.java:410)
                   at weblogic.jspc.runBody()V(jspc.java:319)
                   at weblogic.utils.compiler.Tool.run([Ljava.lang.String;)V(Tool.java:146)
                   at weblogic.utils.compiler.Tool.run()V(Tool.java:103)
                   at weblogic.jspc.main([Ljava.lang.String;)V(jspc.java:708)
              java.lang.Exception: [Compilation errors : ]
              E:\DateBean\__dates.java:134: cannot resolve symbol
              symbol : class DateBean
              location: class jsp_servlet.__dates
              DateBean date = null; //[ /dates.jsp; Line: 13]
              ^
              E:\DateBean\__dates.java:135: cannot resolve symbol
              symbol : class DateBean
              location: class jsp_servlet.__dates
              date = (DateBean)pageContext.getAttribute("date"); //[ /dates.jsp; Line: 13]
              ^
              E:\DateBean\__dates.java:138: cannot resolve symbol
              symbol : class DateBean
              location: class jsp_servlet.__dates
              date = (DateBean)pageContext.getAttribute("date"); //[ /dates.jsp; Line: 13]
              ^
              E:\DateBean\__dates.java:140: cannot resolve symbol
              symbol : class DateBean
              location: class jsp_servlet.__dates
              date = new DateBean(); //[ /dates.jsp; Line: 13]
              ^
              4 errors
                   at weblogic.jspc.doCompile(Ljava.lang.String;Ljava.util.List;Lweblogic.utils.Getopt2;ZLjava.lang.String;)V(jspc.java:842)
                   at weblogic.jspc.runJspc(Lweblogic.utils.classloaders.GenericClassLoader;Ljava.io.File;Ljava.util.Map;Z)V(jspc.java:632)
                   at weblogic.jspc.runBodyInternal()V(jspc.java:410)
                   at weblogic.jspc.runBody()V(jspc.java:319)
                   at weblogic.utils.compiler.Tool.run([Ljava.lang.String;)V(Tool.java:146)
                   at weblogic.utils.compiler.Tool.run()V(Tool.java:103)
                   at weblogic.jspc.main([Ljava.lang.String;)V(jspc.java:708)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    I just wanted to say THANK YOU! This stuff can be a real pain when all the documentation shows everything should be working but it doesn't.
    I will pass on this little piece of info to the next confused person.
    shoot me an e-mail sometime [email protected]

  • Jsp, servlet & bean: trying to display records in a jsp

    Hello i'm trying to display records from my MYSQL database into particular fields allready designed in a jsp. Via servlets and beans i want the records in a jsp.
    I can get the resultset of the record, but can't get the resultset in de fields of the jsp.
    Here are my files:
    SERVLET
    package ...;
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class Zoekklantactie extends HttpServlet {
         ZoekklantBean ZoekklantBean = new ZoekklantBean();
         ZoekklantactieBean ZoekklantactieBean = new ZoekklantactieBean();
         DbBean db = new DbBean();
         public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
              verwerk(request, response);
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
         verwerk(request, response);
    public void verwerk(HttpServletRequest request, HttpServletResponse response) throws IOException {
         response.setContentType("text/html");
              PrintWriter out = response.getWriter();
              String hachternaam = request.getParameter("hachternaam");
              String zoekklantnieuw = "SELECT hachternaam FROM klantgegevens WHERE hachternaam = ";
              String zoekklantnieuw2 = zoekklantnieuw + " '"+hachternaam+"' ";
              ResultSet rs = null;
                   //     out.println("debug 1<br>");
         /*     try {
                   //     Statement s;
                        db.connect();
                   //     s = db.getS();
                        rs = db.execSQL("SELECT hachternaam FROM klantgegevens WHERE hachternaam = 'Opgelder'");
                   //          out.println(rs.getString(1)+"hoi");
                        while (rs.next()) {
                   //                retrieve and print the values for the current row
                   //          out.println("debug1a --> "+rs.toString()+"<br>");
                             String str = rs.getString(1);
                   //          out.println("ROW = " + str );
                        } catch (SQLException e) {
                   //                TODO Auto-generated catch block
                   //          out.println("debug2 <br>"+e.toString());
                             e.printStackTrace();
                        } catch (ClassNotFoundException e) {
                   //                TODO Auto-generated catch block
                   //          out.println("debug3 <br>");
                             e.printStackTrace();
         /* ResultSet rs = null;
         out.println("debug 1<br>");
              try {
                   //     Statement s;
                   db.connect();
                   //     s = db.getS();
                   rs = db.execSQL("select * from klantgegevens where hachternaam = 'Opgelder'");
                   //          out.println(rs.getString(1)+"hoi");
                   while (rs.next()) {
                        rs.first();
                   //           retrieve and print the values for the current row
                        out.println("debug1a<br>");
                        String str = rs.getString(1);
                        System.out.println("ROW = " + str );
                   rs = (ResultSet) db.execSQL(zoekklantnieuw2);
                   out.print(rs.getString("hwoonplaats"));
                   out.print(zoekklantnieuw2);
              } catch (SQLException e) {
                   //                TODO Auto-generated catch block
                   out.println("debug2 <br>"+e.toString());
                   e.printStackTrace();
              } catch (ClassNotFoundException e) {
                   //                TODO Auto-generated catch block
                   out.println("debug3 <br>");
                   e.printStackTrace();
              if( hachternaam == "" ){
                   request.setAttribute("jesper",ZoekklantBean);
                   //          Get dispatcher with a relative URL
                   RequestDispatcher dis = request.getRequestDispatcher("Zoekklant.jsp");
                   //           include
                   try {
                        dis.include(request, response);
                   } catch (ServletException e) {
                        e.printStackTrace();
                   } catch (IOException e) {
                        e.printStackTrace();
                   //          or forward
                   try {
                        dis.forward(request, response);
                   } catch (ServletException e) {
                        e.printStackTrace();
                   } catch (IOException e) {
                        e.printStackTrace();
              else{
                   try {
                   //     Statement s;
                        db.connect();
                   //     s = db.getS();
                        rs = db.execSQL(zoekklantnieuw2.toString());
                   //          out.println(rs.getString(1)+"hoi");
                        while (rs.next()) {
                   //           retrieve and print the values for the current row
                   //          out.println("debug1a --> "+rs.toString()+"<br>");
                             String str = rs.getString(1);
                   //          out.println("ROW = " + str );
                   //          out.print(rs);
                        } catch (SQLException e) {
                   //                TODO Auto-generated catch block
                   //          out.println("debug2 <br>"+e.toString());
                             e.printStackTrace();
                        } catch (ClassNotFoundException e) {
                   //                TODO Auto-generated catch block
                   //          out.println("debug3 <br>");
                             e.printStackTrace();
                   request.setAttribute("jesper",ZoekklantactieBean);
                   //          Get dispatcher with a relative URL
                   RequestDispatcher dis = request.getRequestDispatcher("Zoekresultaatklant.jsp");
                   //          include
                   try {
                        dis.include(request, response);
                        } catch (ServletException e) {
                        e.printStackTrace();
                        } catch (IOException e) {
                        e.printStackTrace();
                   //          or forward
                   try {
                        dis.forward(request, response);
                        } catch (ServletException e) {
                        e.printStackTrace();
                        } catch (IOException e) {
                        e.printStackTrace();
    BEAN
    package ...;
    public class ZoekklantactieBean {
         private String hachternaam;
         private String hvoorletters;
         private String hgeslachtMan;
         private String hgeslachtVrouw;
         private String hgeboortePlaats;
         private String hgeboorteDatum;
         private String hnationaliteit;
         private String hsofinummer;
         private String hadres;
         private String hwoonplaats;
         private String hpostcode;
         private String htelefoonnummerPrive;
         private String htelefoonnummerMobiel;
         private String htelefoonnummerWerk;
         private String hemail;
         private String hburgelijkeStaat;
         private String hallimentatie;
         private String hrestduurAllimentatie;
         private Boolean hbetreftOversluiting;
         private String pachternaam;
         private String pvoorletters;
         private String pgeslachtMan;
         private String pgeslachtVrouw;
         private String pgeboortePlaats;
         private String pgeboorteDatum;
         private String pnationaliteit;
         private String psofinummer;
         private String padres;
         private String pwoonplaats;
         private String ppostcode;
         private String ptelefoonnummerPrive;
         private String ptelefoonnummerMobiel;
         private String ptelefoonnummerWerk;
         private String pemail;
         private String pburgelijkeStaat;
         private String pallimentatie;
         private String prestduurAllimentatie;
         private Boolean poversluiting;
         public void setHachternaam( String name )
         hachternaam = name;
         public String getHachternaam()
         return hachternaam;
         public void setHvoorletters( String name )
         hvoorletters = name;
         public String getHvoorletters()
         return hvoorletters;
         public void setHgeslachtMan( String gender )
         hgeslachtMan = gender;
         public String getHgeslachtMan()
         return hgeslachtMan;
         public void setHgeslachtVrouw( String gender )
         hgeslachtVrouw = gender;
         public String getHgeslachtVrouw()
         return hgeslachtVrouw;
         public void setHgeboortePlaats( String name )
         hgeboortePlaats = name;
         public String getHgeboortePlaats()
         return hgeboortePlaats;
         public void setHgeboorteDatum( String date )
         hgeboorteDatum = date;
         public String getHgeboorteDatum()
         return hgeboorteDatum;
         public void setHnationaliteit( String name )
         hnationaliteit = name;
         public String getHnationaliteit()
         return hnationaliteit;
         public void setHsofinummer( String number )
         hsofinummer = number;
         public String getHsofinummer()
         return hsofinummer;
         public void setHadres( String name )
         hadres = name;
         public String getHadres()
         return hadres;
         public void setHwoonplaats( String name )
         hwoonplaats = name;
         public String getHwoonplaats()
         return hwoonplaats;
         public void setHpostcode( String name )
         hpostcode = name;
         public String getHpostcode()
         return hpostcode;
         public void setHtelefoonnummerPrive( String number )
         htelefoonnummerPrive = number;
         public String getHtelefoonnummerPrive()
         return htelefoonnummerPrive;
         public void setHtelefoonnummerMobiel( String number )
         htelefoonnummerMobiel = number;
         public String getHtelefoonnummerMobiel()
         return htelefoonnummerMobiel;
         public void setHtelefoonnummerWerk( String number )
         htelefoonnummerWerk = number;
         public String getHtelefoonnummerWerk()
         return htelefoonnummerWerk;
         public void setHemail( String adress )
         hemail = adress;
         public String getHemail()
         return hemail;
         public void setHburgelijkeStaat( String name )
         hburgelijkeStaat = name;
         public String getHburgelijkeStaat()
         return hburgelijkeStaat;
         public void setHallimentatie( String number )
         hallimentatie = number;
         public String getHallimentatie()
         return hallimentatie;
         public void setHrestduurAllimentatie( String number )
         hrestduurAllimentatie = number;
         public String getHrestduurAllimentatie()
         return hrestduurAllimentatie;
         public void setHbetreftOversluiting( Boolean choise )
         hbetreftOversluiting = choise;
         public Boolean getHbetreftOversluiting()
         return hbetreftOversluiting;
         public void setPachternaam( String name )
         pachternaam = name;
         public String getPachternaam()
         return pachternaam;
         public void setPvoorletters( String name )
         pvoorletters = name;
         public String getPvoorletters()
         return pvoorletters;
         public void setPgeslachtMan( String gender )
         pgeslachtMan = gender;
         public String getPgeslachtMan()
         return pgeslachtMan;
         public void setPgeslachtVrouw( String gender )
         pgeslachtVrouw = gender;
         public String getPgeslachtVrouw()
         return pgeslachtVrouw;
         public void setPgeboortePlaats( String name )
         pgeboortePlaats = name;
         public String getPgeboortePlaats()
         return pgeboortePlaats;
         public void setPgeboorteDatum( String date )
         pgeboorteDatum = date;
         public String getPgeboorteDatum()
         return pgeboorteDatum;
         public void setPnationaliteit( String name )
         pnationaliteit = name;
         public String getPnationaliteit()
         return pnationaliteit;
         public void setPsofinummer( String number )
         psofinummer = number;
         public String getPsofinummer()
         return psofinummer;
         public void setPadres( String name )
         padres = name;
         public String getPadres()
         return padres;
         public void setPwoonplaats( String name )
         pwoonplaats = name;
         public String getPwoonplaats()
         return pwoonplaats;
         public void setPpostcode( String name )
         ppostcode = name;
         public String getPpostcode()
         return ppostcode;
         public void setPtelefoonnummerPrive( String number )
         ptelefoonnummerPrive = number;
         public String getPtelefoonnummerPrive()
         return ptelefoonnummerPrive;
         public void setPtelefoonnummerMobiel( String number )
         ptelefoonnummerMobiel = number;
         public String getPtelefoonnummerMobiel()
         return ptelefoonnummerMobiel;
         public void setPtelefoonnummerWerk( String number )
         ptelefoonnummerWerk = number;
         public String getPtelefoonnummerWerk()
         return ptelefoonnummerWerk;
         public void setPemail( String adress )
         pemail = adress;
         public String getPemail()
         return pemail;
         public void setPburgelijkeStaat( String name )
         pburgelijkeStaat = name;
         public String getPburgelijkeStaat()
         return pburgelijkeStaat;
         public void setPallimentatie( String number )
         pallimentatie = number;
         public String getPallimentatie()
         return pallimentatie;
         public void setPrestduurAllimentatie( String number )
         prestduurAllimentatie = number;
         public String getPrestduurAllimentatie()
         return prestduurAllimentatie;
         public void setPoversluiting( Boolean choise )
         poversluiting = choise;
         public Boolean getPoversluiting()
              return poversluiting;
    JSP
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="ErrorPage.jsp" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <jsp:useBean id = "db" scope = "request" class = "jesper.DbBean" />
    <jsp:useBean id = "ZoekklantactieBean" scope = "request" class = "jesper.ZoekklantactieBean" />
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Klantinvoer</title>
    <style type="text/css">
    <!--
    .style1 {font-family: Verdana, Arial, Helvetica, sans-serif}
    .style3 {font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; }
    -->
    </style></head>
    <body>
    <form id="Zoekklantactie" name="Zoekklantactie" method="post" action="Zoekklantactie">
    <table width="71%" height="447" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td width="20%"><span class="style1">Zoek klant </span></td>
    <td width="20%"><select name="select">
    <option>H. Patat</option>
    <option>B. Opgelder</option>
    <option>Y. de Koning</option>
    </select> </td>
    <td width="8%"> </td>
    <td width="18%"> </td>
    <td width="20%"> </td>
    <td width="14%"> </td>
    </tr>
    <tr>
    <td><span class="style3">Hoofdaanvrager</span></td>
    <td> </td>
    <td> </td>
    <td><span class="style3">Partner</span></td>
    <td> </td>
    <td> </td>
    </tr>
    <tr>
    <td><span class="style1">Naam</span></td>
    <td><input type="text" name="hachternaam" value ="<jsp:getProperty name ="ZoekklantactieBean" property ="hachternaam" />"/></td>
    <td> </td>
    <td><span class="style1">Naam</span></td>
    <td><input type="text" name="pachternaam" value ="<jsp:getProperty name ="ZoekklantactieBean" property ="pachternaam" />"/></td>
    <td> </td>
    </tr>
    <tr>
    <td><span class="style1">Voorletters</span></td>
    <td><input type="text" name="hvoorletters" value ="<jsp:getProperty name ="ZoekklantactieBean" property ="hvoorletters" />"/></td>
    <td> </td>
    <td><span class="style1">Voorletters</span></td>
    <td><input type="text" name="pvoorletters" value ="<jsp:getProperty name ="ZoekklantactieBean" property ="pvoorletters" />"/></td>
    <td> </td>
    </tr>
         <tr>
    <td><span class="style1">Geslacht</span></td>
    <td><span class="style1">
    <label>
    <input name="hgeslachtMan" type="radio" value="<jsp:getProperty name ="ZoekklantactieBean" property ="hgeslachtMan"/>Man" />
    Man
    <input name="hgeslachtMan" type="radio" value="<jsp:getProperty name ="ZoekklantactieBean" property ="hgeslachtVrouw"/>Vrouw" />
    Vrouw </label>
    </span></td>
    <td><span class="style1"></span></td>
    <td><span class="style1">Geslacht</span></td>
    <td><span class="style1">
    <label>
    <input name="pgeslachtMan" type="radio" value="<jsp:getProperty name ="ZoekklantactieBean" property ="pgeslachtMan" />Man" />
              Man
              <input name="pgeslachtMan" type="radio" value="<jsp:getProperty name ="ZoekklantactieBean" property ="pgeslachtVrouw" />Vrouw" />
              Vrouw </label></span></td>
    <td> </td>
    </tr>
    <tr>
    <td><span class="style1">Geboortedatum</span></td>
    <td><input type="text" name="hgeboorteDatum" value ="<jsp:getProperty name ="ZoekklantactieBean" property ="hgeboorteDatum" />"/></td>
    <td> </td>
    <td><span class="style1">Geboortedatum</span></td>
    <td><input type="text" name="pgeboorteDatum" value ="<jsp:getProperty name ="ZoekklantactieBean" property ="pgeboorteDatum" />"/></td>
    <td> </td>
    </tr>
    <tr>
    <td><span class="style1">Geboorteplaats</span></td>
    <td><input type="text" name="hgeboortePlaats" value ="<jsp:getProperty name ="ZoekklantactieBean" property ="hgeboortePlaats" />"/></td>
    <td> </td>
    <td><span class="style1">Geboorteplaats
    </span></td>
    <td><span class="style1">
    <input type="text" name="pgeboortePlaats" value ="<jsp:getProperty name ="ZoekklantactieBean" property ="pgeboortePlaats" />"/>
    </span></td>
    <td> </td>
    </tr>
    <tr>
    <td><span class="style1">Nationaliteit</span></td>
    <td><input type="text" name="hnationaliteit" value ="<jsp:getProperty name ="ZoekklantactieBean" property ="hnationaliteit" />"/></td>
    <td> </td>
    <td><span class="style1">Nationaliteit</span></td>
    <td><input type="text" name="pnationaliteit" value ="<jsp:getProperty name ="ZoekklantactieBean" property ="pnationaliteit" />"/></td>
    <td> </td>
    </tr>
    <tr>
    <td><span class="style1">Sofinummer</span></td>
    <td><input type="text" name="hsofinummer" value ="<jsp:getProperty name ="ZoekklantactieBean" property ="hsofinummer" />"/></td>
    <td> </td>
    <td><span class="style1">Sofinummer</span></td>
    <td><input type="text" name="psofinummer" value ="<jsp:getProperty name ="ZoekklantactieBean" property ="psofinummer" />"/></td>
    <td> </td>
    </tr>
    <tr>
    <td><span class="style1">Postcode</span></td>
    <td><input type="text" name="hpostcode" value ="<jsp:getProperty name ="ZoekklantactieBean" property ="hpostcode" />"/></td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    </tr>
    <tr>
    <td><span class="style1">Adres</span></td>
    <td><input type="text" name="hadres" value ="<jsp:getProperty name ="ZoekklantactieBean" property ="hadres" />"/></td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    </tr>
    <tr>
    <td><span class="style1">Woonplaats</span></td>
    <td><input type="text" name="hwoonplaats" value ="<jsp:getProperty name ="ZoekklantactieBean" property ="hwoonplaats" />"/></td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    </tr>
    <tr>
    <td><span class="style1">Telefoon prive</span></td>
    <td><span class="style1">
    <input type="text" name="htelefoonnummerPrive" value ="<jsp:getProperty name ="ZoekklantactieBean" property ="htelefoonnummerPrive" />"/></span></td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    </tr>
    <tr>
    <td><span class="style1">Telefoon mobiel </span></td>
    <td><span class="style1">
    <input type="text" name="htelefoonnummerMobiel" value ="<jsp:getProperty name ="ZoekklantactieBean" property ="htelefoonnummerMobiel" />"/></span></td>
    <td> </td>
    <td><span class="style1">Telefoon mobiel</span></td>
    <td><span class="style1">
    <input type="text" name="ptelefoonnummerMobiel" value ="<jsp:getProperty name ="ZoekklantactieBean" property ="ptelefoonnummerMobiel" />"/></span></td>
    <td> </td>
    </tr>
    <tr>
    <td><span class="style1">Telefoon werk </span></td>
    <td><span class="style1">
    <input type="text" name="htelefoonnummerWerk" value ="<jsp:getProperty name ="ZoekklantactieBean" property ="htelefoonnummerWerk" />"/></span></td>
    <td> </td>
    <td><span class="style1">Telefoon werk</span></td>
    <td><span class="style1">
    <input type="text" name="ptelefoonnummerWerk" value ="<jsp:getProperty name ="ZoekklantactieBean" property ="ptelefoonnummerWerk" />"/></span></td>
    <td> </td>
    </tr>
    <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    </tr>
    <tr>
    <td><span class="style1">E-mail</span></td>
    <td><input type="text" name="hemail" value ="<jsp:getProperty name ="ZoekklantactieBean" property ="hemail" />"/></td>
    <td> </td>
    <td><span class="style1">E-mail</span></td>
    <td><input type="text" name="pemail" value ="<jsp:getProperty name ="ZoekklantactieBean" property ="pemail" />"/></td>
    <td> </td>
    </tr>
    <tr>
    <td><span class="style1">Burgelijke staat </span></td>
    <td><select name="hburgelijkeStaat" value ="<jsp:getProperty name ="ZoekklantactieBean" property ="hburgelijkeStaat" />">
    <option selected="selected">gehuwd</option>
    <option>ongehuwd</option>
    <option>gescheiden</option>
    </select> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    </tr>
    <tr>
    <td><span class="style1">Allimentatie</span></td>
    <td><input type="text" name="hallimentatie" value ="<jsp:getProperty name ="ZoekklantactieBean" property ="hallimentatie" />"/></td>
    <td> </td>
    <td><span class="style1">Allimentatie</span></td>
    <td><input type="text" name="pallimentatie" value ="<jsp:getProperty name ="ZoekklantactieBean" property ="pallimentatie" />"/></td>
    <td> </td>
    </tr>
    <tr>
    <td><span class="style1">Restduur allimentatie </span></td>
    <td><input type="text" name="hrestduurAllimentatie" value ="<jsp:getProperty name ="ZoekklantactieBean" property ="hrestduurAllimentatie" />"/></td>
    <td> </td>
    <td><span class="style1">Restduur allimentatie </span></td>
    <td><input type="text" name="prestduurAllimentatie" value ="<jsp:getProperty name ="ZoekklantactieBean" property ="prestduurAllimentatie" />"/></td>
    <td> </td>
    </tr>
    <tr>
    <td><span class="style1">Betreft een oversluiting? </span></td>
    <td><input type="checkbox" name="hbetreftOversluiting" value ="<jsp:getProperty name ="ZoekklantactieBean" property ="hbetreftOversluiting" />Betreft oversluiting" /></td>
    <td> </td>
    </tr>
    </table>
    </form>
    <form name="Terug" method="post" action="Menu.jsp"><input name="Terug" type="submit" value="Terug naar hoofdmenu" /></form>
    </body>
    </html>
    Package everywhere the same.
    Have commented some of the code, because i was trying to debug, but just couldn't figure it out.
    Tnx in advance.
    gr. bopgelder

    put your bean in a different package from servlet and include this
    package in your servlet like
    import yourbeanpackage.yourbean
    and then create object of bean and use it

  • JSP/Servlet/Bean help

    Pretty new to java and I am getting an error that I have tried to figure out for a few days here and ... well... not getting far.
    I have a servlet that calls one of two jsp pages depending on GET or POST. index.jsp is called on GET and works fine. On POST the servlet gets a db pool connection does a quick select count(*) query and then populates a bean with the results. This all works fine (as I have system.out.println's showing me the results)
    But when it forwards to the next jsp page the page bombs out because it can't seem to find the Bean.
    The error is below.
    my set up is Tomcat 4.x
    the main servlet AECPhoneServlet is in ...webapps/damn/WEB-INF/classes
    the bean (QueryBean) is in ...webapps/damn/WEB-INF/classes/com/phone
    jsp's are in ...webapps/damn
    web.xml looks like this
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <servlet>
    <servlet-name>AECPhoneServlet</servlet-name>
    <servlet-class>AECPhoneServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>AECPhoneServlet</servlet-name>
    <url-pattern>/AECPhone</url-pattern>
    </servlet-mapping>
    </web-app>
    Classpath is
    echo $CLASSPATH
    :/usr/tomcat/jakarta-tomcat-4.1.24/webapps/damn/WEB-INF/classes/com/phone:.:/usr/tomcat/jakarta-tomcat-4.1.24/common/lib/servlet.jar
    I am beating my head against the wall here. Any and all help would be greatly appreciated. Assume I know nothing. lol. Because basically I don't.
    ype Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 2 in the jsp file: /rs.jsp
    Generated servlet error:
    [javac] Since fork is true, ignoring compiler setting.
    [javac] Compiling 1 source file
    [javac] Since fork is true, ignoring compiler setting.
    [javac] /usr/tomcat/jakarta-tomcat-4.1.24/work/Standalone/localhost/damn/rs_jsp.java:8: package com does not exist
    [javac] import com.phone;
    [javac] ^
    [javac] /usr/tomcat/jakarta-tomcat-4.1.24/work/Standalone/localhost/damn/rs_jsp.java:45: cannot resolve symbol
    [javac] symbol : class TestBean
    [javac] location: class org.apache.jsp.rs_jsp
    [javac] TestBean tBean = null;
    [javac] ^
    An error occurred at line: 2 in the jsp file: /rs.jsp
    Generated servlet error:
    [javac] /usr/tomcat/jakarta-tomcat-4.1.24/work/Standalone/localhost/damn/rs_jsp.java:47: cannot resolve symbol
    [javac] symbol : class TestBean
    [javac] location: class org.apache.jsp.rs_jsp
    [javac] tBean = (TestBean) pageContext.getAttribute("tBean", PageContext.PAGE_SCOPE);
    [javac] ^
    An error occurred at line: 2 in the jsp file: /rs.jsp
    Generated servlet error:
    [javac] /usr/tomcat/jakarta-tomcat-4.1.24/work/Standalone/localhost/damn/rs_jsp.java:50: cannot resolve symbol
    [javac] symbol : class TestBean
    [javac] location: class org.apache.jsp.rs_jsp
    [javac] tBean = (TestBean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "TestBean");
    [javac] ^
    [javac] 4 errors
         at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:130)
         at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:293)
         at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:353)
         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:370)
         at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:473)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:190)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
         at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:432)
         at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:356)
         at AECPhoneServlet.doPost(AECPhoneServlet.java:56)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
         at java.lang.Thread.run(Thread.java:536)

    my set up is Tomcat 4.x
    the main servlet AECPhoneServlet is in
    ...webapps/damn/WEB-INF/classes
    the bean (QueryBean) is in
    ...webapps/damn/WEB-INF/classes/com/phone
    jsp's are in ...webapps/damn
    /usr/tomcat/jakarta-tomcat-4.1.24/work/Standalone/local
    ost/damn/rs_jsp.java:45: cannot resolve symbol
    [javac] symbol : class TestBean
    [javac] location: class org.apache.jsp.rs_jsp
    [javac] TestBean tBean = null;
    [javac] ^
    I don't know if this is a typo, but above you say the class name is QueryBean. However, the compiler errors refer to a class called TestBean.

  • SOme more help on JSP-Servlets-Beans plz...!!

    Thanx a lot for your help !
    But I could not understand some things ...
    Suppose, I create 5 bean instances in my servlet, & "set" them with data from 5 tuples.
    Now, I need to pass these 5 bean objects to a JSP .
    HOW exactly can I pass them via a List object thru request attribute ?
    And, after doing that, HOW will I be able to access the individual Bean objects in the JSP ?
    Plz., see if you can send me some Code Snippets that illustrate the same.
    Once again, Thanks a lot for bearing with me !!
    Awaiting your response...
    Truly yours,
    Raghu

    Servlet:
    request.setAttribute ("someUniqueName", yourBeanList);
    JSP:
    Either <jsp:useBean> or insert a scriplet like <% List beanList = (List) request.getAttribute("someUniqueName"); %>

  • What are JSP, Servlet , Bean in MVC ??..how does it function?

    suppose there's a bean file (.java) consisting of SQL query, and a servlet (.java) used to show an image, and lastly a jsp page when clicked shows the image.............can you please explain how does this work,how the logic flows,what happens step by step.....i really need to understand this, thankz.

    A JSP page is essentially an easy way to create an abstract behind the scenes servlet where its whole purpose is to serve HTML. JSP tags and java code within the page are processed on the server side first and then a response is sent containing the HTML.
    The JSP can send its request to another handler or servlet that can do the processing.
    I don't understand where a java bean comes into play in this situation.

  • JSP AND BEAN PROBLEm   java.lang.nullpointerexception   help me please

    hello i have a problem, when i open login.jsp and enter the form i have nullpointerexception. i don't understand where i wrong... i use tomcat 5.5 ... sorry for my english i'm italian and i speak only italian :(
    login.jsp this is the code of the java server page
    <html>
    <%@ page language="java" import="java.sql.*" %>
    <jsp:useBean id="lavoro" scope="page" class="Ok.Dino"/>
    <%@ page session="false" %>
    <style type="text/css">
    <!--
    body {
         background-color: #003366;
    a:link {
         color: #CCCCCC;
    .style1 {
         color: #000000;
         font-weight: bold;
         font-size: x-large;
    .style4 {font-size: 18px}
    -->
    </style>
    <body>
    <%if(request.getMethod()=="GET"){
    %>
    <form action="login.jsp" method= "POST" name="frmlogin" id="frmlogin">
         <div align="center">
           <p class="style1">AUTENTICAZIONE</p>
           <p> </p>
           <table width="318" height="140" border="1">
            <tr>
              <td width="95" height="60" bordercolor="#000000" bgcolor="#0066CC"><p align="center"><strong>USER</strong></p>          </td>
              <td width="207" bgcolor="#0099CC"><p align="center">
                <input type="text" name="txtnome"></p>
              </td>
            </tr>
            <tr>
              <td height="72" bordercolor="#000000" bgcolor="#0066CC"><strong>PASSWORD</strong> </td>
              <td width="207" bgcolor="#0099CC"><div align="center">
                <input name="pwdtxt" type="password">
              </div></td>
            </tr>
          </table>
           <table width="318" border="1">
            <tr>
              <td width="318" height="87"> <div align="center">
                <input name="submit" type="submit" value="invia"  >
              </div>
              <p align="center"><strong><span class="style4">Se non sei registrato fallo <a href="file:///C|/Documents and Settings/access/Documenti/My Received Files/registrazione.jsp">adesso </a></span></strong></p></td>
            </tr>
          </table>
           <p> </p>
           <p> </p>
      </div>
    </form>
    <%}else {  %>
    <%lavoro.settxtnome(request.getParameter("txtnome"));%>
    <%!ResultSet rs=null;
         String x=null;
    %>
    <% lavoro.cn_db("dbutenti");%>
    <% rs=lavoro.run_query("SELECT user FROM utenti");%>
    <%}%>
    </body>
    </html>and this is the bean code
    package Ok;
    import java.sql.*;
    public class Dino
    private String txtnome,pwdtxt;
    private Connection cn=null;
    private Statement st=null;
    private ResultSet Rs=null;
    public String gettxtnome()
    return txtnome;
    public String getpwdtxt()
    return pwdtxt;
    public void settxtnome(String n)
    this.txtnome=n;
    public void setpwdtxt(String n)
    this.pwdtxt=n;
    public void cn_db(String db)
              if(cn==null){
              //1. Caricamento del driver
              try{
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              }catch(ClassNotFoundException cnfe){
                   System.out.println("impossibile caricare il driver");
                   System.exit(1);
              try{
                   //2. Connessione al DB
                   cn = DriverManager.getConnection("jdbc:odbc:"+db);
                   //3. creazione degli oggetti Statement e ResultSet
                   st =cn.createStatement();
              }catch(SQLException e){
                   System.out.println(e+"jjj");
    }else{
         System.out.print("errore database gi�� creato");
    public ResultSet run_query(String qr)
         try{
    Rs=st.executeQuery(qr);
         }catch(SQLException e)
         System.out.print(e+"ecco l'error");
         return Rs;
    }

    Do you understand when a NullPointerException will be thrown? This will be thrown if you want to access an uninstantiated Object.
    So look to the stacktrace and go to the line where the NPE is been thrown and doublecheck if the object reference is actually instantiated.
    Or add a null-check to the object reference:if (someObject != null) {
        someObject.doSomething();
    }or just instantiate it:if (someObject == null) {
        someObject = new SomeObject();
    someObject.doSomething();

  • Books / literature on JSP/servets/beans

    Hi,
    Can some one suggest good books/web sites which talks about using JSP/Servlets/Beans in one application
    Thanks
    Raj

    A good site I can think of is "Theserverside.com".

  • Sample JSP&Servlet application required?

    hey all
    iam new to jsp&servlets
    i did read some tutorials about the basics
    and i want any link to a tutorial or a project that uses both jsp&servlets
    any help?

    At the risk of sounding really dumb the examples are just too complex. There does not appear to be anywhere on the web where I can find a simple JSP/servlet/bean example of the type I described. There is enouigh material describing each individual component, but what I need is an example to cement the ideas, but the ones suggested are too much for a newbie. Even the much vaunted Pet Store thingy causes my eyes to glaze over.
    I dont expect anyone to have written something with my exact requirements, but surely to goodness there must be something that:
    1. On entry presents a search form on a table (e.g. EMP)
    2. On submission list all rows in EMp matchiung the criteria.
    3. The user can either click the link 'Edit' which opens up a form dispalying the row allowing the user to edit and save the changes, or click the 'New' button to show a blank form to create a new EMP.
    All this via a Controller servlet, with the database logic handled by a java bean, and all the presentation done via JSP.
    To me this is the most obvious and instructive example of this technology, but after days of trawling the web, and looking through a number of books, I cannot find such a thing.
    CGI with Perl DBI/DBD was a breeze to work with compared to this stuff ..... maybe ASP with SQL/Server would be a more fruitful use of time.

Maybe you are looking for

  • Memory upgrade for Lenovo 3000 V200 - only 2Gb seen :(

    I bought 2 Transcend DDR2 800 SO-DIMM modules 2Gb each to upgrade memory on Lenovo 3000 V200 notebook. When I installed them, BIOS (and Windows) sees only 2Gb instead of 4Gb (i use x64 OS so no prob with OS here). When I install one of new modules an

  • Solution Manager - initial configuration

    Lance, I apologize before hand, I think I am missing something simple or I am clueless right now, Here is my situation- I am walking through the IMG steps of setting up solution Manager. I already in have in place the SNC SAProuter connection operati

  • Send query's result via SMS (BW3.0b)

    Hi we need to send query's results via sms. We're going to use reporting agent (we configured an exception in bex and created a follow up action). Now I can only send a SAP office message. In order to send a sms, could you help me to understand which

  • Can't replace existing workbook

    We are having an issue moving in a workbook that is already in quality.  I created it then somebody else changed it in Quality and should not have so now I am trying to re-transport it and it fails.  Is it due to the owner now being the other person

  • Css and target blank

    Hello, I have many pages that open via image links. Can I create a CSS rule where I can have all these pages that are opened via image links, open in a blank page. I know that I can do it one a time by clicking on the image link and choosing target >