Using Beans in jsp

hi all,
i am using bean in my jsp page.but it is not working it shows error. i have run this with even Tomcat or WebLogic. even i have just Copy paste code from net.
the code is
index.jsp
<%@ page errorPage="errorpage.jsp" %>
<jsp:useBean id="counter" scope="session" class="beans.Counter" />
<html>
<head>
<title>Session Bean Example 1</title>
</head>
<body>
<H3>Session Bean Example 1</H3>
<center><b>The current count for the counter bean is: </b>
<%=counter.getCount() %></center>
</body>
</html>
Bean -Counter.java
package beans;
import java.io.Serializable;
public class Counter implements Serializable{
int count = 0;
public Counter(){
public int getCount() {
count++;
return this.count;
public void setCount(int count) {
this.count = count;
and error on browser is
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /index.jsp(3,0) The value for the useBean class attribute beans.Counter is invalid.
     org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)
     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
org.apache.jasper.JasperException: /index.jsp(3,0) The value for the useBean class attribute beans.Counter is invalid.
     org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
     org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
     org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:146)
     org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1174)
     org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1116)
     org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
     org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
     org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
     org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
     org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
     org.apache.jasper.compiler.Generator.generate(Generator.java:3320)
     org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
     org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
     org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
     org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
     org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)
     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.20 logs.
Please let me know how can i handle this situation

Try this
After<hsp:useBean>
<jsp:setProperty name="counter" property="setCounter" value=1 />
<jsp:getProperty name="counter" property="getCounter" />

Similar Messages

  • Error while using Beans in JSP

    I am using netbeans to develop the applications and am using tomcat version (jakarta-tomcat-4.1.18).
    When I execute the following program i get the below mentioned error::
    StringBean.java
    package test;
    import java.beans.*;
    public class StringBean {
    private String message = "No message SPECIFIED";
    public String getMessage() {
    return message;
    public void setMessage(String message) {
    this.message = message;
    StringBean.jsp
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE>Using JavaBeans with JSP </TITLE>
    <LINK REL=STYLESHEET HREF="JSP-Styles.css" TYPE="text/css" >
    </HEAD>
    <body
    <jsp:useBean id = "SB" class = "test.StringBean" />
    initial value is : <jsp:getProperty name = "SB" property= "message"/>
    <jsp:setProperty name= "SB" property = "message" value= "this the message after the change"/>
    final value is :<jsp:getProperty name = "SB" property= "message"/>
    </body>
    </HTML>
    javax.servlet.ServletException: test/StringBean
    at org.netbeans.modules.tomcat.tomcat40.runtime.IDEJspServlet.service(IDEJspServlet.java:349)
         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:243)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
         at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
         at java.lang.Thread.run(Thread.java:536)
    Root Cause
    java.lang.NoClassDefFoundError: test/StringBean
         at java.lang.Class.getDeclaredConstructors0(Native Method)
         at java.lang.Class.privateGetDeclaredConstructors(Class.java:1590)
         at java.lang.Class.getConstructor0(Class.java:1762)
         at java.lang.Class.newInstance0(Class.java:276)
         at java.lang.Class.newInstance(Class.java:259)
    at org.netbeans.modules.tomcat.tomcat40.runtime.IDEJspServlet$JspServletWrapper.load(IDEJspServlet.java:106)
         at org.netbeans.modules.tomcat.tomcat40.runtime.IDEJspServlet$JspServletWrapper.loadIfNecessary(IDEJspServlet.java:150)
         at org.netbeans.modules.tomcat.tomcat40.runtime.IDEJspServlet$JspServletWrapper.service(IDEJspServlet.java:160)
         at org.netbeans.modules.tomcat.tomcat40.runtime.IDEJspServlet.serviceJspFile(IDEJspServlet.java:246)
         at org.netbeans.modules.tomcat.tomcat40.runtime.IDEJspServlet.service(IDEJspServlet.java:339)
         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:243)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
         at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
         at java.lang.Thread.run(Thread.java:536)

    Ok The class isn't found, so your classpath settings of netbeans (if you are using the run function in netbeans) isn't set.
    and if you aren't using netbeans to run it, then the class isn't in the webapp/WEB-INF/classes
    good luck

  • Use bean in jsp, please help me out

    Hi all,
    As a beginner in jsp I want to use a bean into my jsp page. But this bean is sourcing from a old applet (i've converted the code applet into beans code), and should return a chart (grpahics).
    Here is the heart of my problem : how can i replace, call , or set up the paint method from the applet. And call it into my jsp page in order to retrieve a chart ?
    Basically all applet shall have a paint method with a Graphics argument , in jsp i can't do
    Mypackage.mybean.paint(Graphics g);
    Hope someone will be able to help me
    Thanks in advance
    Shamann

    I don't think that you can use the Graphics object in a JSP. A JSP is executed on the server side and only the output from that will be sent to the client. If you want to use Graphics objects etc, I think that you'll have to send it to an applet (possibly embedded in the page), but since I've never done this, I can't help you, I'm afraid.
    HTH,
    Raj.

  • Calling a Jdialog from javascript using bean in JSP

    Hello all...
    In my jsp page , I have a button , onclicking it a javascript is called and in that javascript a bean is called to show a JDialog window. In that Jdialog window , I have a JTable, Accept button and Cancel Button..
    But the JavaScript is not calling bean...
    sample code :
    <input type ="submit" name="submit" onclick="func()">
    <script language ="javascript">
    func(){
    beanid.fn();
    </script>
    and in MyClass.fn(){
    codes for display is written......
    Is there anything wrong in this approach or if any other solution will to my needs please let me know..
    Regards
    SunilrKP

    Where is the JavaBean? Are you using an (J)Applet to deploy the bean to the client? If so then you might want to hop on over to the [Applet Forum|http://forums.sun.com/forum.jspa?forumID=421] to see what the problem is. When you do, show them the JavaScript you use to access the Applet.
    If you are not deploying the JavaBean via an Applet, then the class lives on the Server, while JavaScript lives on the Client - two different machines separated by space and time. You will need to change your approach (ie deploy the bean via an Applet or don't stop trying to use Swing as display over HTTP).

  • Using beans with jsp

    Hi
    i am using tomcat 6.0 and jdk 1.6u17
    i am trying to use a bean to connect to MySql db using jsp page but i keep getting the error :
    org.apache.jasper.JasperException: org.apache.jasper.JasperException: Unable to load class for JSP
    i read about it and i think that it is unable to locate my bean class file
    here is the beanDb.java
    package beans;
    import java.sql.;
    import java.io.;
    public class beanDb
    private Connection dbCon;
    String path="jdbc:mysql://localhost:3306/dbname?user=username&password=pwd";
    String dbDriver="com.mysql.jdbc.Driver";
    public beanDb()
    super();
    public boolean connect() throws ClassNotFoundException,SQLException
    Class.forName(dbDriver);
    dbCon = DriverManager.getConnection(path);
    return true;
    public void close() throws SQLException
    dbCon.close();
    public void path()
    public ResultSet execSQL(String sql) throws SQLException
    Statement s = dbCon.createStatement();
    ResultSet r = s.executeQuery(sql);
    return (r == null) ? null : r;
    public int updateSQL(String sql) throws SQLException
    Statement s = dbCon.createStatement();
    int r = s.executeUpdate(sql);
    return (r == 0) ? 0 : r;
    and the jsptest.jsp code is :
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
    <jsp:useBean id="beanDb" class="beanDb" scope="request" />
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>
    <body>
    <%
    out.println(beanDb.connect());
    %>
    </body>
    </html>
    the location of these files are :
    C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\myApp\WEB-INF\classes\beans\beanDb.java
    C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\myApp\jsptest.jsp
    Please suggest a solution..
    Thanks

    http://forums.sun.com/thread.jspa?threadID=5423314

  • Using beans with jsp without any ide

    Hi
    i am using tomcat 6.0 and jdk 1.6u17
    i am trying to use a bean to connect to MySql db using jsp page but i keep getting the error :
    org.apache.jasper.JasperException: org.apache.jasper.JasperException: Unable to load class for JSP
    i read about it and i think that it is unable to locate my bean class file
    here is the beanDb.java
    package beans;
    import java.sql.*;
    import java.io.*;
    public class beanDb
         private Connection dbCon;
         String path="jdbc:mysql://localhost:3306/dbname?user=username&password=pwd";
         String dbDriver="com.mysql.jdbc.Driver";
         public beanDb()
              super();
         public boolean connect() throws ClassNotFoundException,SQLException
    Class.forName(dbDriver);
    dbCon = DriverManager.getConnection(path);
    return true;
         public void close() throws SQLException
         dbCon.close();
         public void path()
         public ResultSet execSQL(String sql) throws SQLException
              Statement s = dbCon.createStatement();
    ResultSet r = s.executeQuery(sql);
    return (r == null) ? null : r;
         public int updateSQL(String sql) throws SQLException
         Statement s = dbCon.createStatement();
    int r = s.executeUpdate(sql);
    return (r == 0) ? 0 : r;
    and the jsptest.jsp code is :
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
    <jsp:useBean id="beanDb" class="beanDb" scope="request" />
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>
    <body>
    <%
                   out.println(beanDb.connect());
                   Connection connection;
                   Statement stmt = null;
                   ResultSet rs = null;
    %>
    </body>
    </html>
    the location of these files are :
    C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\ROOT\myApp\WEB-INF\classes\beans\beanDb.java
    C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\ROOT\myApp\jsptest.jsp
    Please suggest a solution..
    Thanks

    here is the changed code but still the same error:
    package beans;
    import java.sql.;
    import java.io.;
    public class beanDb
    private Connection dbCon;
    String path="jdbc:mysql://localhost:3306/dbname?user=username&password=pwd";
    String dbDriver="com.mysql.jdbc.Driver";
    public beanDb()
    super();
    public boolean connect() throws ClassNotFoundException,SQLException
    Class.forName(dbDriver);
    dbCon = DriverManager.getConnection(path);
    return true;
    public void close() throws SQLException
    dbCon.close();
    public void path()
    public ResultSet execSQL(String sql) throws SQLException
    Statement s = dbCon.createStatement();
    ResultSet r = s.executeQuery(sql);
    return (r == null) ? null : r;
    public int updateSQL(String sql) throws SQLException
    Statement s = dbCon.createStatement();
    int r = s.executeUpdate(sql);
    return (r == 0) ? 0 : r;
    and the jsptest.jsp code is :
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
    <jsp:useBean id="beanDb" class="beanDb" scope="request" />
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>
    <body>
    <%
    out.println(beanDb.connect());
    %>
    </body>
    </html>
    the location of these files are :
    C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\myApp\WEB-INF\classes\beans\beanDb.java
    C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\myApp\jsptest.jsp

  • Java.lang.NoSuchMethodError using beans and JSP

    Hi,
    I get a
    java.lang.NoSuchMethodError: Unit.UnitBean.execSQL(Ljava/lang/String; Ljava/sql/ResultSet;
    when i try to call that method from my jsp page. I can call all other methods in teh bean but I can't understand why it can't find execSQL when it finds every thing else.
    Any help would be greatly appreciated.
    Mike
    Heres a copy of my java bean code:
    package Unit;
    import java.sql.*; 
    import java.io.*; 
    public class UnitBean
         Connection con;
         String error;
         public boolean connect() throws ClassNotFoundException,SQLException
              String StudentNumber = "xxx";
              String strHost = "xxxx";
              String strConnectURL = ("jdbc:postgresql://" + strHost + "/");
              String strUser = "xxxx";
              String strPassword = "xxxxx";
              Class.forName("org.postgresql.Driver");
              con = DriverManager.getConnection(strConnectURL, strUser, strPassword);     
              return true;
         public void disconnect() throws SQLException
              con.close();
         public ResultSet execSQL(String sql)throws SQLException
              Statement s = con.createStatement();
              ResultSet rs = s.executeQuery(sql);
              return rs;
         public String test()
              String Mike="HIHIHIHIHI";
              return Mike;
    }And the jsp code:
    <%@ page language="java" contentType="text/html"%>
    <%@ page import="java.sql.*" %>
    <%@ page import="java.io.*" %>
    <jsp:useBean id="Unit" class="Unit.UnitBean" scope="page"/>
    <html>
         <head>
              <title>Test My Bean!!!!???!!?!</title>
         </head>
         <body>
              <%
                   String SQL ="Select * from unit where unitid='CMPS2B26'";
                   ResultSet rs =null;
                   try
                        Unit.connect();
                        rs = Unit.execSQL(SQL);
                        while(rs.next())
                                  out.println(rs.getString("unitid"));
                        Unit.disconnect();     
                   catch(Exception e)
                        out.println("<p>Problem with jsp code" +e);
              %>
              This is a jsp page.
              <p><a href = "http://stuweb3.cmp.uea.ac.uk/~xxxx/index.html">Click here for home page</a>
         </body>
    </html>

    Yeah, that worked great, thanks a lot. I thought that JSP compiled when you changed it and then visited it, but i've tried that. I just ran ant stop start on my server and it's all working.
    Thanks again :)
    Mike

  • Error when use Bean in JSP... Help!

    -- JSP File --
    <%@ page import="com.puppet.javabean.database.DBBean" %>
    <jsp:useBean      id="connectionPool"
              scope="application"
              class="DBBean" >
    <jsp:setProperty     name="connectionPool"
              property="Driver"
              param="driver"
              value="system" />
    </jsp:useBean>
    -- JavaBean --
    import java.io.Serializable;
    public class DBBean implements Serializable
    private String driver;
    void setDriver(String driver)
         System.out.println("------------"+driver+"------------");
         this.driver = driver;
    public String getDriver()
         return driver;     
    But it gen. error in Tomcat.
    -- Error --
    org.apache.jasper.JasperException: Cannot find any information on property 'Driver' in a bean of type 'DBBean'
    at org.apache.jasper.runtime.JspRuntimeLibrary.introspecthelper(Unknown
    Source)
    how can i solve this ?
    Thx a lot

    [Servlet.LOG]: account: init
    [1/21/05 15:37:59:234 IST] 6ab9ec7e WebGroup E SRVE0020E: [Servlet Error]-[account]: Failed to load servlet: javax.servlet.ServletException: Failed to load JSP file: /JSP/account.jsp
    com.ibm.ws.webcontainer.servlet.LoadTargetServletFailure: Failed to load target servlet [account]

  • Cannot resolve the symbol while using use bean in jsp

    Hi,
              Jsp with weblogic version 4.5 were running fine. When running on
              weblogic server 6.1 I get an error while running jsp pages cannot resolve
              symbol
              probably due to
              <jsp:useBean id = "hmllinkbean1" class="com.accupac.html.htmllink.LinkRS"/>
              I have the bean classes in
              config/accudomain/applications/DefaultWebApp_myserver/Web-inf/classes/
              and jsp files in the directory
              config/accudomain/applications/DefaultWebApp_myserver/
              Any help will be appreciated.
              Thanks
              madhu
              

    Three possibilities:
              Is your directory name really "Web-inf"? That will not work. It needs to be "WEB-INF".
              In WEB-INF, do you have:
              classes/com/accupac/html/htmllink/LinkRS.class
              When you say "cannot resolve symbol", is it the LinkRS class that it can't resolve?

  • Use beans in jsp

    Hi,
    I have a file called "SAXParserBean.java" in /WEB-INF/classes/beans/xml/sax and another file called "SAXElement.java" in /WEB-INF/classes/beans/xml/sax.
    I have compiled SAXElement.java successfully and get the SAXElement.class, but when I compile
    SAXElement.java, I got the following errors :
    ==============
    C:\Program Files\Allaire\JRun\servers\default\default-app\WEB-INF\classes\beans\
    xml\sax>javac SAXParserBean.java
    SAXParserBean.java:16: Class beans.xml.sax.SAXElement not found.
    private SAXElement currentElement=null;
    ^
    SAXParserBean.java:32: Class beans.xml.sax.SAXElement not found.
    currentElement = new SAXElement(uri, localName, qName, attrs);
    ^
    SAXParserBean.java:33: Class beans.xml.sax.SAXElement not found in void startEle
    ment(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attribute
    s).
    vector.addElement(currentElement);
    ^
    SAXParserBean.java:50: Invalid left hand side of assignment.
    if (currentElement!=null && elementText1=null)
    ^
    4 errors
    ==========================
    It seemed that it don't recoginze the SAXElement.class, do anybody know why??
    It's urgent, if anybody knows,please let me know, thanks.
    Thanks,
    ED

    1. Seems like we have missed beans.xml.sax.SAXElement.class in classpath.
    2. SAXParserBean.java:50: Invalid left hand side of assignment.    if (currentElement!=null && elementText1=null)
                                                ^
                                                 \_ This must be == (not a single =)

  • Beans through jsp

    hi,
    i' m trainee developer and working in struts. i'm totally novice in this regard. my pl asked me to develop an application on struts. i'm getting problem while using bean through jsp. i'm writing code:
    <jsp:useBean id="myBean" class="MyBean" type="MyBean" scope = "session"/>
    the error is:
    cannot resolve symbol
    symbol : class MyBean
    location: class org.apache.jsp.confirm_jsp
    MyBean myBean = null;
    ^
    total 3 errors associated with it. MyBean class is located in WEB-INF/classes
    can any one help me out?

    put your bean in a package and put that package under the WEB-INF/classes directory. Then use the fully qualified class name for the jsp:useBean:
    //in the bean
    package net.thelukes.myprog.beans;
    //the jsp:useBean
    <jsp:useBean id="myBean" class="net.thelukes.myprog.beans.MyBean" scope="session"/>

  • How To Use EJB in JSP

    I've used beans in JSP.. but how to use EJB's in beans ??
    EJB's are deployed in Oracle 8i
    Please Help
    Thank You.

    Please find the answer in this HOWTO:
    http://technet.oracle.com:89/ubb/Forum2/HTML/006404.html
    HOWTO's are archived on the JDeveloper Documentation page:
    http://technet.oracle.com/docs/products/jdev/listing.htm (Click on Documentation Tab)
    Thanks,
    -Roel.

  • Using JavaBeans into JSP

    I have a simple example for using Beans in JSP and the problem is that i get this error: org.apache.jasper.JasperException: /BeanCounter.jsp(8,0) The value for the useBean class attribute Counter is invalid.
    The program's ideea is to count how many times i've accesed the bean
    This is the code: (i'm using Apache Tomcat 5.5)
    My bean (Counter):
    import java.io.Serializable;
    public class Counter implements Serializable{
    int count = 0;
    public Counter() {
    public int getCount() {
    count++;
    return this.count;
    public void setCount(int count) {
    this.count = count;
    and the code for BeanCounter.jsp :
    <HTML>
    <HEAD>
    <TITLE>JSP Bean Example</TITLE>
    </HEAD>
    <BODY>
    <%@ page language="java" %>
    <jsp:useBean id="counter" scope="session" class="Counter" /> //i guess that here is the problem but i don't have a package or anything else
    <jsp:setProperty name="counter" property="count" param="count" />
    <%
    out.println("Count from scriptlet code : "
    + counter.getCount() + "<BR>");
    %>
    <!-- Get the bean's count property, -->
    <!-- using the jsp:getProperty action. -->
    Count from jsp:getProperty :
    <jsp:getProperty name="counter" property="count" /><BR>
    </BODY>
    </HTML>
    The Counter.class is in WEB-INF/classes
    I just cannot understand why it doesn't work. Please help :) Thanks in advance

    So put your class in a package, and it should work fine.
    package mypackage;
    import java.io.Serializable;
    import java.io.Serializable;
    public class Counter implements Serializable {
         int count = 0;
         public Counter() {
         public int getCount() {
              count++;
              return this.count;
         public void setCount(int count) {
              this.count = count;
    }and in your JSP:
    <jsp:useBean id="counter" scope="session" class="mypackage.Counter" />
    The class then moves to be WEB-INF/classes/mypackage/Counter.class
    Also, your original post was missing a closing '}' on the Counter class.

  • Database connection using beans

    Hi, I'm very new to JSP. I'm trying to write an application which has a Login page which the user uses to login to a Oracle database (with their own User ID and password). Once the user has successfully logged in I would like to use the same connection to all the other pages the user is traversing until the user logs out. I have come to know that this is possible using beans in JSP or using the connection pool, but I'm not 100% sure how. Can someone please provide me some sample code of the Login page, the beans and a third page which uses the connection. I really appreciate your time and efforts. Thanks a lot in advance for all your efforts and support.
    Cheers
    Balaji

    What you have to learn is how to use session variables after you have successfully logged in your pages. What the next succeeding pages will do is to check if this session variable is not null or valid and then proceed with the display of the pages or redirect it to the login page otherwise. You can implement this sesion variable as a bean to store all the details for a particular user.
    Typically you will use
    Object o = session.getAttribute("yourSessionVariable");
    if (o ==null)
    // go to login page OR
    // create a session variable
    // like session.setAttribute("yourSessionVariable", new Object());
    }else
    //proceed with the display
    Here, o is your bean.
    Hope this helps

  • Problem with JSP using bean packaged in jar file

    Hi,
              I am trying to use a java bean in a jsp file. The java bean is packaged
              into a jar file. I am getting class not found compilation error. If the
              bean remains to be a seperated class file, everything work well.
              Does anyone know how I can use bean in a jar file within jsp , i.e. to
              allow the bean to be found during compilation ?
              Thanks,
              Terence.
              [email protected]
              

    Jacek,
              Thanks for replying.
              My JSP's are just files in my document root . However, I found a solution to
              my
              problem. That is to have the jar file defined in my weblogic.class.path. I may
              have missed some files in my original jar file which causes my problem.
              Mayby I should package everything into a web application for deployment. That
              will be my next step.
              Thanks anyway.
              Terence.
              Jacek Laskowski wrote:
              > Terence Lai wrote:
              > >
              > > Hi,
              > >
              > > I am trying to use a java bean in a jsp file. The java bean is packaged
              > > into a jar file. I am getting class not found compilation error. If the
              > > bean remains to be a seperated class file, everything work well.
              >
              > How do you use the JSP file ? Is it a part of web application ? If so,
              > the bean jar package should be located in WEB-INF/lib directory. It's
              > also recommended to put the bean class into a package, so it's not in
              > 'unnamed' package, and <jsp:useBean> can find it.
              >
              > >
              > > Does anyone know how I can use bean in a jar file within jsp , i.e. to
              > > allow the bean to be found during compilation ?
              >
              > see above.
              >
              > > Terence.
              >
              > Jacek Laskowski
              > HP Consulting
              

Maybe you are looking for

  • Transfer Safari bookmarks to new MacBook Pro

    I just got a new MB Pro yesterday and would like to transfer my bookmarks from my older SR MB. So I "exported" them to a jump drive and then transferred that file "Safari Bookmarks.html" to my new desktop. I then went into Safari and tried the "impor

  • Strange behaviour of a panel in InDesign CS6

    I am currently developing a panel running on InDesign CS5, CS5.5 and CS6. For some internal specific reason, the panel (of type csxs:CSXSWindowedApplication) has its visible property set to false; in its "Lifecycle", the autovisible is unselected and

  • Use of q operator in oracle 11g

    Hi, I am looking for following data Rewards–ALL (UK/IE,US,Germany & China). even though i have used q operator. when report is generated using following query and UTL_FILE in excel sheet it show following data Rewardsâ€"ALL (UK/IE,US,Germany & China)

  • Loan Enhancement - repayment and interest pay seperately.

    Hi Friends, I have an requirement, whereby  the employees will repay the principal first; when the principal is cleared, then repay the total interest accumulated in the previous repayment periods. For example, employee took a loan of Rs. 50,000 @ 7.

  • JSP - prefix error - need resolution

    Hi all (Charles, Todd, Mike & others), @ the ND4 to iPlanet migration project, we have failed to get the JSP loaded in iPlanet. The exception displayed in the KJS follows below. We are not sure what this implys and how to resolve it (Does it require