SetProperty in JSP with JavaBeans

Why do they always talk about the following code in JSP's for getting or setting property's in a JavaBean.
<jsp:setProperty name="dbb" property="dbDriver" value="<%= set.getDbDriver()%>" />
Because it is also possible by just calling this "dbb.setDbdriver(set.getDbDriver())" setting-methode.
Is there also a specific code to call normal methods, no set or get method, of a JavaBean in a JSP
for something like "dbb.execSQL(String sql)".

One of the reasons for JSPs existence is to separate the presentation logic from the business and control logic. The rationale is that the skills required to design a user interface are different than programming skills, so creators and maintainers of JSPs may not be Java programmers. In this scenario, there is no Java scripting in a JSP. All data and business logic is encapsulated in beans and/or custom tags accessed from the page. That's why the useBean, getProperty and setProperty tags exist. Check out the web for info on the Model, View, Controller framework.
There are no built-in JSP tags to call bean methods that require arguments or do not have get/set methods. Custom tags could do this job if necessary.
Whether you follow this approach is your call and, among other things, depends on the skills of those who will be maintaining your JSPs in the future.

Similar Messages

  • Errors in a program jsp with javabeans

    With the following program time.jsp from the book bigjava by
    horstmann, I get from tomcat 5.0 the following errors. Who helps me?
    My O.S. is win pro.
    Thanks
    Eugenia Mariani
    this is the program:
    time.jsp
    inside the folder
    C:\Programmi\Apache Software Foundation\Tomcat 5.0\webapps\bigjava
    <jsp:useBean id="formatter" class="TimeFormatterBean"/>
    <jsp:setProperty name="formatter" property="date" value="<%= new
    java.util.Date() %>"/>
    <html>
    <head>
    <title>Time JSP</title>
    </head>
    <body>
    <h1>Time JSP</h1>
    <p>The current time is:
    <jsp:getProperty name="formatter" property="time"/>
    </p>
    </body>
    </html>
    this is the program TimeFormatterBean.java with
    TimeFormatterBean.class
    inside the folder:
    C:\Programmi\Apache Software Foundation\Tomcat
    5.0\webapps\bigjava\WEB-INF\classes
    import java.text.DateFormat;
    import java.util.Date;
    This bean formats the time of day from a given date.
    public class TimeFormatterBean
    Initializes the formatter.
    public TimeFormatterBean()
    timeFormatter = DateFormat.getTimeInstance();
    Write-only date property.
    @param aDate the date to be formatted.
    public void setDate(Date aDate)
    theDate = aDate;
    Read-only time property.
    @return the formatted time
    public String getTime()
    String timeString = timeFormatter.format(theDate);
    return timeString;
    private DateFormat timeFormatter;
    private Date theDate;
    these are the errors fro TOMCAT 5.0
    HTTP Status 500 -
    type Exception report
    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    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: 1 in the jsp file: /time.jsp
    Generated servlet error:
    [javac] Compiling 1 source file
    C:\Programmi\Apache Software Foundation\Tomcat
    5.0\work\Catalina\localhost\bigjava\org\apache\jsp\time_jsp.java:42:
    cannot resolve symbol
    symbol : class TimeFormatterBean
    location: class org.apache.jsp.time_jsp
    TimeFormatterBean formatter = null;
    ^
    An error occurred at line: 1 in the jsp file: /time.jsp
    Generated servlet error:
    C:\Programmi\Apache Software Foundation\Tomcat
    5.0\work\Catalina\localhost\bigjava\org\apache\jsp\time_jsp.java:44:
    cannot resolve symbol
    symbol : class TimeFormatterBean
    location: class org.apache.jsp.time_jsp
    formatter = (TimeFormatterBean)
    jspxpage_context.getAttribute("formatter", PageContext.PAGE_SCOPE);
    ^
    An error occurred at line: 1 in the jsp file: /time.jsp
    Generated servlet error:
    C:\Programmi\Apache Software Foundation\Tomcat
    5.0\work\Catalina\localhost\bigjava\org\apache\jsp\time_jsp.java:46:
    cannot resolve symbol
    symbol : class TimeFormatterBean
    location: class org.apache.jsp.time_jsp
    formatter = new TimeFormatterBean();
    ^
    An error occurred at line: 10 in the jsp file: /time.jsp
    Generated servlet error:
    C:\Programmi\Apache Software Foundation\Tomcat
    5.0\work\Catalina\localhost\bigjava\org\apache\jsp\time_jsp.java:63:
    cannot resolve symbol
    symbol : class TimeFormatterBean
    location: class org.apache.jsp.time_jsp
    out.write(org.apache.jasper.runtime.JspRuntimeLibrary.toString((((Time
    FormatterBean)_jspx_page_context.findAttribute("formatter")).getTime()
    ^
    4 errors
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultError
    Handler.java:83)
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.
    java:306)
    org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:398)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:441)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:422)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.
    java:507)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.
    java:274)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:29
    2)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    note The full stack trace of the root cause is available in the Apache
    Tomcat/5.0.24 logs.
    Apache Tomcat/5.0.24

    Cross Post
    http://forum.java.sun.com/thread.jsp?thread=526883&forum=45&message=2528346

  • Problem linking jsp with javabeans

    Hey guys,
    I am new at this jsp stuff, but have read a few threads as well as a few tutorials. however, i dont understand why i keep getting this error. any help would be appreciate it!
    i m currently running it off tomcat 4.1, and the hierarchy that i have currently is set like this:
    "xxx/build/array.jsp"
    "xxx/build/WEB-INF/classes/arraymap/javaBeans/ArraysBean.java"
    the content of my jsp is as follows:
    <%@ page import="arraymap.javaBeans.ArraysBean" %>
    <html>
    <head>
         you are in the array page!
    </head>
    <jsp:useBean id="test" class="arraymap.javaBeans.ArraysBean" scope="page"/>
    <body>
    <a href="index.html"> LOG OUT</a>
    <center>
    Please choose one of the following queries:
    </h3>
    </center>
    </body>
    </html>and my simple bean code:
    package arraymap.javaBeans;
    import java.util.*;
    import arraymap.*;
    public class ArraysBean {
        ArrayMapModMain a = ArrayMapModMain.instance();
        public Object[] getArrayTypes()
         return a.getArrayTypes();
    }but i get this error:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 6 in the jsp file: /cds_jsp/build/array.jsp
    Generated servlet error:
    [javac] Compiling 1 source file
    C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\cds_jsp\build\array_jsp.java:7: package arraymap.javaBeans does not exist
    import arraymap.javaBeans.ArraysBean;
    ^
    C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\cds_jsp\build\array_jsp.java:46: package arraymap.javaBeans does not exist
    arraymap.javaBeans.ArraysBean test = null;
    ^
    An error occurred at line: 6 in the jsp file: /cds_jsp/build/array.jsp
    Generated servlet error:
    C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\cds_jsp\build\array_jsp.java:48: package arraymap.javaBeans does not exist
    test = (arraymap.javaBeans.ArraysBean) pageContext.getAttribute("test", PageContext.PAGE_SCOPE);
    ^
    An error occurred at line: 6 in the jsp file: /cds_jsp/build/array.jsp
    Generated servlet error:
    C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\cds_jsp\build\array_jsp.java:51: package arraymap.javaBeans does not exist
    test = (arraymap.javaBeans.ArraysBean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "arraymap.javaBeans.ArraysBean");
    ^
    4 errors
    any idea on why i cant recognize the package? the file is on the tomcat server (the class file is physically there when i manually check it), and i couldnt figure out what i went wrong with either the jsp or hte beans. i have been stuck on this problem for several hours and it is painful sitting in a cube not knowing what is goin on. any help would be GREATLY appreciated! thanks in advance!
    kev

    I copied your files into my environment and it worked fine for me (I had to strip out the ArrayMapModMain stuff to get a compilation though), so it looks like an environment thing as opposed to an issue with your code.
    Possibilities include (shots in the dark):
    1.) The path it showed in the error messages
    "C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\cds_jsp\build\array_jsp.java"
    looks a little funny, mainly the underscore between localhost and cds_jsp. Maybe there's something wrong in your Tomcat config file (see #3).
    2.) Maybe your directory has a permissions issue. Is it readable? Likely not an issue as you're using windows, but it bites me all the time in linux.
    3.) I haven't used Tomcat in a while, but I'll bet it has a config file. Are you sure it's pointing to your WEB-INF/classes dir for your servlets?
    Sorry I can't be of more help.
    jengi

  • HELP! Beginning JSP with JavaBean Class

    First of all, I'm using jdk1.4 beta and Jakarta's tomcat version 4.0.1 release build.
    Hello. I desparately need help. I have a JavaBean class ("CarBean.class") saved in %catalina_home%\webapps\root\myapp\web-inf\classes\com\wrox\cars\CarBean.class
    I also have a jsp page saved as carpage.jsp in %catalina_home%\webapps\root\myapp\
    So when I point my browser to http://localhost:8080/myapp/carpage.jsp, I get an internal server error. It appears it can't find the JavaBean class for some reason. I'm pretty sure I have my envionment variables set up right. I can get it to work, if I save the JavaBean class in c:\jdk1.4\jre\class\com\wrox\cars
    Here's my JavaBean class source file:
    package com.wrox.cars;
    import java.io.Serializable;
    public class CarBean implements Serializable {
    public CarBean() {
    private String make = "Ford";
    public String getMake() {
    return make;
    public void setMake(String make) {
    this.make = make;
    and here's my jsp page:
    <html>
    <head>
    <title>Using a JavaBean</title>
    </head>
    <body>
    <h2>Using a JavaBean</h2>
    <% com.wrox.cars.CarBean myCar = new com.wrox.cars.CarBean(); %>
    I own a <%= myCar.getMake() %>
    <% myCar.setMake("Ferrari"); %>
    Now I own a <%= myCar.getMake() %>
    </body>
    </html>
    I'm not new to java, just JSP. I just don't know why I can't get the jsp to locate the JavaBean class. I remember I used to have an older version of Tomcat and I recall not having any problems. It seems the Tomcat 4.XX is somewhat significantly different than previous versions. Perhaps I configured my Tomcat wrong? Help would be greatly appreciated. Thanks.

    hi
    i am not using Tomcat server but as i worked in JWS you have to import the bean class from jsp files.
    so the first code in jsp file will be like this
    <%@ page import = "CarBean">
    becoz JWS cant automatically find the bean class we have to explicitly import bean.but i dont know if tomcat finds
    bean or one have to import.
    hope this will help u.
    regards
    manoj choudhury.

  • JSP with JavaBeans

    Hello,
    I'm trying to write my first page of JSP using a JavaBean.
    I've created a simple bean :
    package dalpkg;
    public class DalBean
    public DalBean()
    setName("DIMA");
    private String myName;
    public void setName(String name)
    this.myName=name;
    public String getName()
    return myName;
    }Now i've created a JSP :
    <jsp:useBean class="dalpkg.DalBean" id="info" scope="session"> 
    <html> 
    <head> 
    <title>Simple JSP Document</title> 
    </head> 
    <body> 
    Initial name is <%=info.getName()%><br> 
    <% info.setName("Adi"); %> 
    New name is <%=info.getName()%><br>
    </body> 
    </html>
    </jsp:useBean>I'm Getting this error : "/DIMA/hello.jsp(1,1) The value for the useBean class attribute dalpkg.DalBean is invalid"
    I couldn't find the solution any where.
    Where should I put the .Java file for it to work?
    Could this be the reason why this isnt working?

    Well thats wierd.. the class file looks ok.. starts just like you said CA FE BA BE.
    Recomiling didnt help..
    but this code works :
    package dalpkg;
    public class HelloWorld
    public void HelloWorld()
    public String ReturnHello()
    return "Hello";
    <jsp:useBean class="dalpkg.HelloWorld" id="info" scope="session"> 
    <html> 
    <head> 
    <title>Simple JSP Document</title> 
    </head> 
    <body> 
    Print Hello :  <%=info.ReturnHello()%><br> 
    </body> 
    </html>
    </jsp:useBean>Edited by: dimamah on Mar 6, 2009 4:43 PM

  • First Try and JSP with JavaBeans

    Hi:
    I've installed Tomcat 3.3.2, and have made no configuration changes.
    I'm trying to create a JSP that uses a JavaBean. This is my first attempt, and there's nothing exciting about my try.
    Below is the JavaBean, that compiles just fine:
    import java.io.Serializable;
    import java.util.*;
    import java.text.*;
    public class today implements Serializable {
    public String getToday() {
    Date df = new Date();
    String today = DateFormat.getDateInstance().format(df);
    return today;
    The class for this .java file is stored in webapps\exampiles\web-inf\classes
    Here is the JSP file:
    <%@ page language="java" import="today" %>
    <jsp:useBean id="jsp" class="today" scope="session" /></jsp:useBean>
    <html><body>
    Today is: //<%= getToday() %>
    </body></html>
    This is stored in webapps\examples\jsp.
    When I try to run the JSP, I receive the following:
    Method getToday() not found in class jsp.today_3.
    out.print( getToday() );
    I have tried many things, but have not succeeded.
    Any suggestions? Thanks.

    <%@ page language="java" import="today" %>
    <jsp:useBean id="jsp" class="today" scope="session"
    /></jsp:useBean>
    <html><body>
    Today is: //<%= getToday() %>
    </body></html>
    }You're not referencing your bean instance when you're trying to access the getToday() method in the code above. It should be jsp.getToday()

  • How to Upload in Servlet or JSP with JavaBean?

    Anybody used to be familiar with these techs?I want to implement a function of upload files.Can you help me with some suggestions?

    Hi,
    This might help you
    read the file and upload to database
    Read that file using java.io.
    File f= new File("give the file name");
    FileInputStream fis= new FileInputStream(f);
    byte[] data= null;
    Vector tempVector = new Vector();
    int tempInt=fis.read();
    while(tempInt!=-1){
    tempVector.add(new Byte((byte)tempInt));
    tempInt=fis.read();
    data= new byte[tempVector.size()];
    for(int k=0;k<tempVector.size();k++){
    data[k]=new Byte(tempVector.get(k).toString()).byteValue();
    System.out.println("The byte[] data is : " +data);
    stmt= conn.prepareStatement("insert into <tableName>(blobValue, key) values ( ? , ? ) " );
    stmt.setObject(1,data);
    stmt.setString(2,"filename");
    stmt.executeUpdate();

  • The deployment problem in JSP using JavaBean

    Hi there,
    I followed the descriptions in Writing Enterprise Applications with
    Java 2 SDK, Enterprise Edition tutorial to build a set of programs to run JSP with JavaBean, and I also followed the steps in creating new WAR file, but some how it wouldn't work after I deployed them. I run the JSP in IE and got a message like this:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 20 in the jsp file: /1bonus.jsp
    Generated servlet error:
    c:\j2sdkee1.3.1\repository\orbit\web\JSPRoot\$1bonus$jsp.java:63: Class org.apache.jsp.JBonusBean not found.
    JBonusBean jbonus = null;
    ^
    I used the deploytool to create the WAR file, and after I added the 1bonus.jsp, I also added JBonusBean into the WAR file. I found 1bonus.jsp was added into the WAR file, but there's no JBonusBean appeared under the WAR file.
    Could you please tell me is there anything wrong?
    Thanks for your time.
    Regards,
    Eric

    I think you have not imported 'BonusBean' in your jsp. Code this line in your jsp at the top.
    <%@page import="BonusBean" %>
    Sudha

  • Problem with JavaBeans in JSP.IT'S URGENT!!!

    Hi, i have problems with JavaBeans in JSP.
    In a jsp file( locating in ROOT directory of tomcat 4.0.6 :jakarta-tomcat-4.0.6\webapps\root ) i have this code:
    <jsp:useBean id="paramBean" class="licentza.ParamBean" />
    <jsp:setProperty name="paramBean"
    property="nume"
              value='<%= request.getParameter("numeUser") %>' />
    where ParamBean it's a "bean" class locating in jakarta-tomcat-4.0.6\webapps\examples\web-inf\classes\licentza (licentza is the package i'm using).
    And i get this error:
    Generated servlet error:
    D:\jakarta-tomcat-4.0.6\work\Standalone\localhost\_\dora\intrare2$jsp.java:67: Class licentza.ParamBean not found.
    ParamBean paramBean = null;
    What is the problem?Thank you.

    Hi,
    Put the class file or the package under :jakarta-tomcat-4.0.6\webapps\root\WEB-INF\classes.
    Rajesh

  • Help with jsp and javaBean in eclipse/Tomcat

    Hi,
    I am new to JSP and JavaBean. I am going through tutorial for a jsp page that uses a javaBean. I am using eclipse to create jsp page and the java bean.
    My eclipse project "Date" has five package as under:-
    1. Deployment Descriptor
    2. Java Resources: src
    3. build
    4. WebContent
    I have my data.jsp page in WebContent/WEB-INF/ folder. When I just run date.jsp in a browser as: http://localhost:8080/Date/date.jsp, it gets launched into the browser correctly. But when I add a JavaBean "TimeFormatterBean.java" in the Java Resources:src folder and use it in date.jsp page, I get errors as under:-
    org.apache.jasper.JasperException: Unable to compile class for JSP:
    An error occurred at line: 5 in the jsp file: /date.jsp
    TimeFormatterBean cannot be resolved to a type
    2: pageEncoding="ISO-8859-1"%>
    3: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    4:
    5: <jsp:useBean id="formatter" class="TimeFormatterBean"/>
    6:
    7: <html>
    8: <head>
    The data.jsp page is as under:-
    <jsp:useBean id="formatter" class="TimeFormatterBean"/>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
         <h1> Date JSP </h1>
         <p> The  current time is:
         <%= new java.util.Date() %>
         <jsp:getProperty name="formatter" property="name"/>
         </p>
    </body>
    </html>I can see "TimeFormatterBean.class" in build/classes folder.
    If anyone could please help me out with this, it would be very helpful
    Thanks a lot!

    You probably should place TimeFormatterBean inside a package, or maybe you could try importing it , even if it�s in the default package, with something like this <%@ page import="TimeFormatterBean" %> at the top

  • Getting error while passing implicit request object from JSP to JavaBean

    Hi,
    I am getting error while passing implicit object ie( request object)
    from within JSP to JavaBean.
    Following is source for JSP, JavaBean and Error message I am getting.
    vaLookup.jsp Source
    <jsp:useBean id="db" class="advisorinsight.javabeans.DisplayPages"
    scope="request">
    <jsp:setProperty name="db" property="request" value="<%= request %>"
    />
    </jsp:useBean>
    <jsp:getProperty name="db" property="totalrecords" />
    JAVABEAN DisplayPages.java source
    package javabeans;
    import java.io.Serializable;
    import javax.servlet.http.HttpServletRequest;
    public final class DisplayPages implements Serializable {
    private String totalrecords;
    private HttpServletRequest request;
    public void setRequest(HttpServletRequest req){
    this.request = req;
    public java.lang.String getTotalrecords()
    this.totalrecords =
    this.request.getParameter("totalrecords");
    return this.totalrecords;
    public DisplayPages(){
    totalrecords = "";
    request = null;
    error after executing vaLookup.jsp
    [30/Nov/2001 11:56:04:5] info: EXTMGR-006: GXExtensionManager: Extension
    service JavaExtData successfully loaded
    [30/Nov/2001 11:56:04:5] info: EXTMGR-006: GXExtensionManager: Extension
    service LockManager successfully loaded
    [30/Nov/2001 11:56:04:5] info: EXTMGR-006: GXExtensionManager: Extension
    service RLOPManager successfully loaded
    [30/Nov/2001 11:56:04:5] info: REQ-012: thread add
    [30/Nov/2001 11:56:04:5] info: REQ-012: thread add
    [30/Nov/2001 11:56:04:5] info: REQ-012: thread add
    [30/Nov/2001 11:56:04:5] info: REQ-012: thread add
    [30/Nov/2001 11:56:04:5] info: REQ-012: thread add
    [30/Nov/2001 11:56:04:5] info: REQ-012: thread add
    [30/Nov/2001 11:56:04:5] info: REQ-012: thread add
    [30/Nov/2001 11:56:04:5] info: REQ-012: thread add
    [30/Nov/2001 11:56:04:7] info: ENGINE-ready: ready: 10819
    [30/Nov/2001 11:56:46:0] info: --------------------------------------
    [30/Nov/2001 11:56:46:0] info: JSPRunnerSticky: init
    [30/Nov/2001 11:56:46:0] info: --------------------------------------
    [30/Nov/2001 11:56:51:7] error: Exception: SERVLET-compile_failed:
    Failed in compiling template: /va/valookup.jsp, javac error:
    c:\iplanet\ias6\ias\APPS\variabl
    S\va\valookup.java:76: Undefined variable: JSP_8
    db.setRequest(_JSP__8);
    ^
    1 error
    Exception Stack Trace:
    java.lang.Exception: javac error:
    c:\iplanet\ias6\ias\APPS\variableannuity\va\WEB-INF\compiled_jsp\jsp\APPS\va\valookup.java:76:
    Undefined variable: JSP_8
    db.setRequest(_JSP__8);
    ^
    1 error
    at
    com.netscape.server.servlet.jsp.JSPCompiler.compileJSP(Unknown Source)
    at
    com.netscape.server.servlet.jsp.JSPCompiler.compileOrLoadJSP(Unknown
    Source)
    at
    com.netscape.server.servlet.jsp.JSPCompiler.compileInstance(Unknown
    Source)
    at
    com.netscape.server.servlet.jsp.JSPCompiler.compileInstance(Unknown
    Source)
    at
    com.netscape.server.servlet.platformhttp.PlatformHttpServletResponse.callJspCompiler(Unknown
    Source)
    at
    com.netscape.server.servlet.platformhttp.PlatformHttpServletResponse.callUri(Unknown
    Source)
    at
    com.netscape.server.servlet.platformhttp.PlatformHttpServletResponse.callUriRestrictOutput(Unknown
    Source)
    at
    com.netscape.server.servlet.platformhttp.PlatformRequestDispatcher.forward(Unknown
    Source)
    at com.netscape.server.servlet.jsp.JSPRunner.service(Unknown
    Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
    at
    com.netscape.server.servlet.servletrunner.ServletInfo.service(Unknown
    Source)
    at
    com.netscape.server.servlet.servletrunner.ServletRunner.execute(Unknown
    Source)
    at com.kivasoft.applogic.AppLogic.execute(Unknown Source)
    at com.kivasoft.applogic.AppLogic.execute(Unknown Source)
    at com.kivasoft.thread.ThreadBasic.run(Native Method)
    at java.lang.Thread.run(Thread.java:479)

    The only thing that I see that looks funny to me is when you pass the request object into the method using <%=request%>, Im not sure whats going to happen here because that is suppose to print the results. Have you tried simply using <%request%>?

  • Jsp and JavaBean problem

    Hi All,
    I need UR help
    Problem:
    I have a javaBean and a jsp page say test.class and test.jsp respectively.
    Now the problem is when i run my jsp in web browser with path
    http://localhost:8080/mypackage/test.jsp and use test.class in it. It give me an error Class test.class Not Found but when i give the path http://localhost:8080/examples/jsp/parentpackage/mypackage/test.jsp
    it works fine.
    I am using Tomcat 3.2 and i have already made changes in server.xml for my jsp files thats why i can run my programs with the earlier path but dont know why its giving the error when i use javabean,
    Also i have put my javabean class in---parentpackage/mypackage/test.class
    Thanks
    Amit

    hi there,
    Thanks for you time, here i have placed the source for jsp and javabean
    Please excuse me if you find the code unproper
    Code for JSP:
    <%
    response.setHeader("Pragma","No-cache");
    response.setDateHeader("Expires",0);
    response.setHeader("Cache-control","No-cache");
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Internal Clarification-Agent View</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body background="images/c.jpg" bgproperties="fixed">
    <%@ page language="java" import="java.sql.*" %>
    <%@ page import="javax.servlet.*" %>
    <%@ page import="java.io.*" %>
    <%@ page import="java.util.*" session="true"%>
    <%@ page import="java.util.Date" %>
    <%@ page import="java.sql.Timestamp" %>
    <%@ page import="java.text.*" %>
    <%@ page import="java.lang.*" %>
    <%@ page import="javax.servlet.http.*"%>
    <jsp:useBean id="navi" class="arvato.interclarification.rqchunk" scope="session" />
    <%
    try{
    Connection con = null;
    PreparedStatement ps = null;
    PreparedStatement ps1 = null;
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection("jdbc:odbc:interdsn","","");
    String qrno = request.getParameter("qrno");
    String rdb = request.getParameter("rb");
    String key = request.getParameter("key");
    String cname = request.getParameter("cname");
    //out.print(key);
    //if(st.equals("All")){
    String sql="";
    if(rdb!=null){
    if(rdb.equals("1")){
    if(qrno==null||qrno.equals("")){
    sql = "SELECT * FROM crequired ORDER BY adate DESC";
    else if(qrno!=null){
    sql = "SELECT * FROM crequired WHERE queryno LIKE '"+qrno+"%'";
    }else if(rdb.equals("2")){
    if(key==null||key.equals("")){
    sql = "SELECT * FROM crequired ORDER BY adate DESC";
    else if(key!=null){
    sql = "SELECT * FROM crequired WHERE clarification LIKE '"+key+"%'";
    else if(rdb.equals("3")){
    if(cname==null||cname.equals("")){
    sql = "SELECT * FROM crequired ORDER BY adate DESC";
    else if(cname!=null){
    sql = "SELECT * FROM crequired WHERE fname LIKE '"+cname+"%'";
    if(rdb==null)
    sql = "SELECT * FROM crequired ORDER BY adate DESC";
    ps = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
    //ps.setString(1,space);
    /*}else{
    sql = "SELECT * FROM crequired WHERE status=? AND space=?";
    ps = con.prepareStatement(sql);
    ps.setString(1,st);
    ps.setString(2,space);
    ResultSet rs = ps.executeQuery();
    %>
    <table width="100%" border="0" cellspacing="0">
    <tr>
    <td width="50%"><strong><img src="images/microsoftlogo1.jpg" width="288" height="94"></strong></td>
    <td width="50%"><div align="right"><strong><img src="images/logo2.jpg" width="177" height="77"></strong></div></td>
    </tr>
    </table><br>
    <hr noshade color="#000000">
    <div align="center"><font color="#990000" size="4" face="Verdana, Arial, Helvetica, sans-serif"><strong>CSR
    VIEW</strong></font>
    </div>
    <form name="form" method="post" action="agentview1.jsp">
    <table width="59%" border="1" align="center" cellpadding="2" cellspacing="0">
    <tr>
    <td width="49%"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>
    <input name="rb" type="radio" value="1" <%if(rdb!=null){if(rdb.equals("1")){out.print("checked");}}%>>
    <font size="1">SEARCH BY QUERY NUMBER:</font></strong></font></td>
    <td width="51%"><input name="qrno" type="text" id="qrno"></td>
    </tr>
    <tr>
    <td><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    <input type="radio" name="rb" value="2" <%if(rdb!=null){if(rdb.equals("2")){out.print("checked");}}%>>
    <font size="1"> SEARCH BY KEY WORD:</font></font></strong></td>
    <td><input name="key" type="text" id="key"></td>
    </tr>
    <tr>
    <td><input type="radio" name="rb" value="3" <%if(rdb!=null){if(rdb.equals("3")){out.print("checked");}}%>>
    <strong><font size="1" face="Verdana, Arial, Helvetica, sans-serif">SEARCH
    BY CSR NAME:</font></strong></td>
    <td><input name="cname" type="text" id="cname"></td>
    </tr>
    <tr>
    <td colspan="2"><div align="center">
    <input type="submit" name="Submit" value="Submit">
    </div></td>
    </tr>
    </table>
    </form><br>
    Back
    <%
    navi.setchunk(10);
    navi.setRS(rs);
    String v="";
    String vv=request.getParameter("off");
    if(vv==null){v="1";}
    else{
    v=vv;
    int i=Integer.parseInt(v);
    navi.setcursor(i);
    ResultSet rs2=navi.getRS();
    int h1=1;
    if(request.getParameter("off")!=null) h1=Integer.parseInt(request.getParameter("off"));
    int h2= navi.getchunk();
    int h3= navi.getcount();
    int offset=(h3-h1)<h2?h3:(h1+h2-1);
    %>
    <table width=100%><tr><td width=33%> </td><td align=center width=34%><font face="verdana, arial" size=2 color=#000000>Displaying <%=h1%> to <%=offset%> of <font size=4><%=h3 %></font></font></td><td width=33%> </td></tr></table>
    <%
    int c1=navi.getcount(),c2=navi.getchunk();
    int c3=navi.getcursor();
    int c4=c3+c2;
    int c5=c3-c2;
    %>
    <table width=100% ><tr><td align=left width=100% >
    <%
    if(c3>c2 && c3<=c1){
    out.print("<a href=\"agentview1.jsp?n=y&off="+c5+"\">Previous</a>");
    %></td><td align=right width=100%>
    <%
    if(c1>c2 && (c1-c3)>=c2){
    out.print("<a href=\"agentview1.jsp?n=y&off="+c4+"\">Next</a>");}
    %>
    </td></tr></table>
    <table width="1359" border="0" cellspacing="1">
    <tr bgcolor="#3C6C84">
    <th width="2%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">S.No.</font></th>
         <th width="5%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Query No</font></th>
    <th width="5%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Clarification
    Posting Date & Time</font></th>
         <th width="3%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Posted
    By</font></th>
    <th width="6%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Received
    By</font></th>     
    <th width="3%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Sub
    Process </font></th>
         <th width="4%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Region</font></th>
    <th width="5%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Status</font></th>     
    <th width="15%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Clarification
    Required OnQuery </font></th>
    <th width="18%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Solution</font></th>
    <th width="8%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Date
    & Time Visited On</font></th>
    <th width="7%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Date
    & Time Closed On</font></th>
    <th width="5%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Remarks</font></th>
    </tr>
    <%
    int m = 0;
    for(int l=0;l<c2 && i<=c1;l++,i++){
    //while(rs.next()){
    m = m+1;
    String queryno = rs.getString("queryno");
    //out.print(queryno);
    %>
    <tr>
    <td bgcolor="#FFFFCC"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><%=m%></b></font></td>
         <td width="5%" bgcolor="#FFE4CA"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><%=queryno%></b></font></td>
    <td bgcolor="#FFFFCC"><font face="Verdana, Arial, Helvetica, sans-serif" size="1">
    <%Date d1 = rs.getDate("adate");
         String dd1="";
         SimpleDateFormat sddf = new SimpleDateFormat("MM/dd/yyyy");
         dd1 = sddf.format(d1);
         Date t1 = rs.getTime("atime");
         String tt1="";
         SimpleDateFormat stdf = new SimpleDateFormat("HH:mm");
         tt1 = stdf.format(t1);
         String ttm = dd1+" "+tt1;
         out.print(ttm);     
         %></font>
    </td>
         <td bgcolor="#FFE4CA"><font face="Verdana, Arial, Helvetica, sans-serif" size="1">
    <b><%String fnm = rs.getString("fname");
    String lnm = rs.getString("lname");
    String nm = fnm+" "+lnm;
    out.print(nm);
    %></b></font></td>
    <td width="6%" bgcolor="#FFFFCC"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><%
         String tnm = rs.getString("tname");
         if(tnm.equals("null")||tnm.equals("-")){}else{out.print(tnm);}
         %></font></td>
         <td bgcolor="#FFE4CA"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><%=rs.getString("space")%></b></font></td>
         <td bgcolor="#FFFFCC"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><%String rg = rs.getString("region");
         if(rg==null||rg.equals("null")){}else{out.print(rg);}%></b></font></td>
         <%String status = rs.getString("status");
         if(status.equalsIgnoreCase("New")){%><td bgcolor="#FF0000"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#FFFFFF"><b><%=status%></b></font></td>
         <%}else if(status.equalsIgnoreCase("Open")||status.equalsIgnoreCase("Awaiting MS Reply")){%><td bgcolor="#FFCC33"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#FFFFFF"><b><%=status%></b></font></td><%}else{%><td bgcolor="#00CC00"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#FFFFFF"><b><%=status%></b></font></td><%}%>
    <td bgcolor="#FFE4CA"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#0000CC"><%=rs.getString("clarification")%></font></td>
         <%
    //String queryno = rs.getString("queryno");
    String qry1 = "select * from csolution where queryno=?";
    ps1 = con.prepareStatement(qry1);
    ps1.setString(1,queryno);
    ResultSet rs1 = ps1.executeQuery();
    while(rs1.next()){%>
    <td bgcolor="#FFFFCC"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><%=rs1.getString("solution")%></font></td>
         <td bgcolor="#FFE4CA"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><%
         Date dp = rs1.getDate("dateofopen");
         String dp1="";
         SimpleDateFormat spdf = new SimpleDateFormat("MM/dd/yyyy");
         dp1 = spdf.format(dp);
         Date tp = rs1.getTime("timeofopen");
         String tp1="";
         SimpleDateFormat stpf = new SimpleDateFormat("HH:mm");
         tp1 = stpf.format(tp);
         String tpm = dp1+" "+tp1;
         out.print(tpm);
         %></font>
    </td>
         <td width="5%" bgcolor="#FFFFCC"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><%
         Date dc = rs1.getDate("dateofclose");
         String dc1="";
         SimpleDateFormat scdf = new SimpleDateFormat("MM/dd/yyyy");
         dc1 = scdf.format(dc);
         Date tc = rs1.getTime("timeofclose");
         String tc1="";
         SimpleDateFormat stcf = new SimpleDateFormat("HH:mm");
         tc1 = stcf.format(tc);
         String tcm = dc1+" "+tc1;
         out.print(tcm);
         %></font>
    </td>
         <td width="16%" bgcolor="#FFE4CA"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><%String remarks = rs1.getString("remarks");
         if(remarks==null){}else{out.print(remarks);}
         %></font></td>
    <%}navi.setcursor();
    }con.close();}catch(Exception e){out.print(e);}%>
    </tr>
    </table><br>
    <font size="2" face="Verdana, Arial, Helvetica, sans-serif">Back to
    Main Menu</font>
    </body>
    </html>
    Code for javaBean:
    package arvato.interclarification;
    import javax.servlet.http.*;
    import java.sql.*;
    public class rqchunk
              ResultSet rs=null;
              int chunk=5;
              int count=0;
              int cursor=1;
              public rqchunk(){}
              public void setRS(ResultSet rset) throws SQLException
                   rs = rset;
                   int cnt=0;
                   while(rs.next())
                        cnt++;
                   rs.absolute(1);
                   count=cnt;
              public void setcursor()throws SQLException
                   cursor++;
                   rs.absolute(cursor);
              public void setcursor(int i)throws SQLException
                   cursor=i;
                   rs.absolute(cursor);
              public int getcursor()
                   return cursor;
              public int getchunk()
                   return chunk;
              public void setchunk(int i)
                   chunk=i;
              public void setcount(int j)
                   count=j;
              public int getcount()
                   return count;
              public ResultSet getRS()
                   return rs;
              public void clearRS()
                   cursor=0;
                   rs=null;
    Please excuse me if my codes are not understandable enough
    Thanks
    Amit

  • Two JSPs using JavaBeans

    Hi,
    I have a JSPs and JavaBeans question.
    There are two JSP files. One.jsp and Two.jsp.
    One.jsp include code that use the JavaBeans from Two.jsp:
    <%
         if (bl.getDmlOperation() == NcepConstants.UPDATE) {
    Two.jsp have:
    <jsp:useBean      id="bl"     class="TestsPrivateBean" scope="session"/>
    <%@ include file="One.jsp" %>
    When I run this code in TOMCAT, it can run in runtime with no problem.
    But the company it now moving to use an IDE (Oracle JDeveloper 9i) with require me to build this into one project. When I try to build the project, it shows error in One.jsp as "variable bl not found in class_One".
    When I put the <jsp:useBean      id="bl"     class="TestsPrivateBean" scope="session"/> code into Two.jsp, it shows "duplicate found error".
    How should I do to fix this?
    Thanks
    Kenny

    It sounds like it's compiling One.jsp independant of Two.jsp, which will cause the first error. Try renaming One.jsp to One.inc or something. That way it doesn't try compiling One.jsp at all (it won't be there).

  • Any CASE tools for Java, JSP, and JavaBeans?

    For Java, JSP, and JavaBeans can we find something that can help us automate certain tasks?
    For example, CASE tools is an acronym for Computer Aided Software Engineering tools. I have a colleague use software to generate robust code for the database layer and with a few clicks of a button after the database is designed he can generate code that would otherwise take an hour or even hours to write and debug and test.
    Thanks for your time and help in advance!
    Cecilia

    The ones I know are MVCase (from Brazil) and Jude (from Japan). Both are free and I haven't fully tested them yet. It may help you.

  • JSP using JavaBeans

    Hello
    Does anyone know of any examples i can look at for using JSP's with JavaBeans.
    Thanks
    Jazci

    Look here:
    http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/JSPBeans.html#62069

Maybe you are looking for

  • HT201263 My phone is stuck on insert usb cable connect to itunes screen. this happened during my iOS 7 update.

    I was updating my iPhone 4S to the iOS 7 system. During update my phone froze. It's stuck on insert USB cable connect to itunes screen. I've already tried turning my phone off holding Home key while inserting my cord into phone and nothing worked. I'

  • Error message I need a handle on.

    Does anyone know what this message really means? ZenRC32.exe - Entry Point Not Found "The procedure entry point FT_Exit4 could not be located in the dymanic link library KERNEL32.dll." I get it on a Windows XP Pro w/SP2 computer that was updated from

  • Should I auto update iTunes and Quicktime?

    the System update asks me to update iTunes and Quicktime but I think the versions are incompatible to this version. This computer is old dog slow. Would it be slower if i upgraded to the latest OS? Is it even possible. Thanks. Will

  • Installation failure - destination folder

    I can not install the Acrobat XI Pro download - I am being told that a version of Acrobat already exists in the destination folder.

  • Epson filter failed

    I tried to print to my Epson Artisan 810 today and it has repeatedly failed.  It keeps saying that the "filter failed."  I checked the discussions here and other forums and the most common solution is to redownload the drivers from Epson.  I tried th