Classes & Beans

I have a valid class name that I would like to create a bean with. My bean does not allow an empty constructor (MyBean() ).
I'm doing the following:
Class newClass = Class.forName(className);
How can I create a new instance of my bean using that class? I cannot do:
Bean bean = (Bean)newClass; since I have to pass some parameters to my bean.
In addition, the bean name will NOT be available to me at design time, it will only be pass to me as a parameter...
Any ideas?

Declare a static factory method in the bean that takes the said parameters. (sory for the tabs that disappear...)
Bean class:
public class Bean
     private String myName = null;
     public Bean( String name )
          myName = name;
     public static Bean createInstance( String s )
          return new Bean( s );
     public String getName()
          return "My name is " + myName;
Loading class:
public class BeanLoader
     public static void main( String[] args )
          try
               Class beanClass = Class.forName( "Bean" );
               Method method = beanClass.getDeclaredMethod(
                    "createInstance",
                    new Class[]{ String.class } );
               Bean bean = ( Bean ) method.invoke( null, new Object[]{ "MyName" } );
               System.out.println( bean.getName() );
          catch( Exception ex )
               ex.printStackTrace();
}

Similar Messages

  • Java class bean can not access to DB in JSP file

    Hi, I wrote a java class bean in order to access to MySql database ,and this bean is used in a JSP file,so that the bean can query from DB and then display the queried information on the JSP file,but it can not work correctly,the following is the source code and error message popup by the system,
    does anybody has experience in solving thus question,Please reply ,Thank you for your help.
    %@ page contentType="text/html;charset=UTF-8" language="java" %>
    <%@ page import = "java.sql.*" %>
    <jsp:useBean id="conn" scope="page" class="news.conn"/>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>1</title>
    <style>
    <!--
    A:link {
         COLOR: #993399
    .s {
         FONT-SIZE: 13px; LINE-HEIGHT: 170%; FONT-FAMILY: "utf-8"
    -->
    </style>
    </head>
    <body>
    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
    <tr>
    <td width="100%">
    <img border="0" src="images/ruanjian.jpg" width="770" height="154"></td>
    </tr>
    <tr>
    <td width="100%">@</td>
    </tr>
    </table>
    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber2">
    <tr>
    <td width="13%">@</td>
    <td width="87%">
    <img border="0" src="images/mid-rdxw2.gif" width="101" height="18"><p>
    <%
              ResultSet rs,rsNest;
    String strSql=null;
    strSql = "select * from news where TYPE=1";     
              rs = conn.executeQuery(strSql);
              while (rs.next()){
    %>
    <span class="s"> <a href="newsContent.jsp?newsId=<%=rs.getInt(id")%">"><%=rs.getString("Title")%></a><br>
    <%
    %>
    <p>
    <img border="0" src="images/mid-hyxw2.gif" width="94" height="19"></p>
    <%
    strSql="select * from news where TYPE=2";     
              rs = conn.executeQuery(strSql);
              while (rs.next()){
    %>
    <span class="s"> <a href="newsContent.jsp?newsId=<%=rs.getInt("id")%>"><%=rs.getString("Title")%></a><br>
    <%
    %>
    <p>@</td>
    </tr>
    </table>
    <p align="center">Study Online</p>
    <p align="center">@</p>
    </body>
    </html>
    Error message:
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Exception in JSP: /newsMain.jsp:47
    44: strSql = "select * from news where TYPE=1";     
    45:           rs = conn.executeQuery(strSql);
    46:           
    47:           while (rs.next()){
    48:
    49: %>
    50:
    Stacktrace:
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:451)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    root cause
    java.lang.NullPointerException
         org.apache.jsp.newsMain_jsp._jspService(newsMain_jsp.java:98)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.27 l</a>

    nogoodatcoding wrote:
    Tolls wrote:
    Is that Jasper Exception telling us where the problem is in the jsp, though?
    If it is, then "rs" is null in the call rs.next()...which means conn.executeQuery() is returning null. Which means that whatever class conn is (news.conn?) has a problem maybe?That's possible. Though, it may just be the case that the 'conn' object itself is null! That line is the first place where it's being used and there are no checks that I can see...we'll have to wait for the OP to investigate and reply I guess.That's what I originally thought, then I noticed it was saying line 47, which is the rs.next() line. Assuming Jasper is correct in its choice of line, then it's the rs that's null. Which means the conn is doing strange things.
    Edit: Now that I think about it, going by the previous thread the OP posted, I'm wondering whether news.conn class is their attempt to move the JDBC stuff out of the JSP page, and it's grabbing the "real" connection (java.sql.Connection) and getting the result set and returning it...or getting something wrong and returning null.
    Edited by: Tolls on 11-Jun-2009 12:24

  • Jsp:useBean : Missing value of String classed bean with 'session' scope

    Hi!
    I'd like to ask some help.
    I have these two JSP pages:
    1.jsp<jsp:useBean id="str" class="java.lang.String" scope="session"/>
    <html>
    <body>
    <% str="hello"; %>
    <a href="2.jsp">click</a>
    </body>
    </html>
    2.jsp<jsp:useBean id="str" class="java.lang.String" scope="session"/>
    <html>
    <body>
    <%=str%>
    </body>
    </html>When I open 1.jsp in my browser, then click on the link, the result is "nothing" (empty string). Why does the bean lose its value on the way?
    I use a Tomcat 5.5.9 server.
    Any help will be highly appreciated.

    You have to think of several scopes when working with JSP. The first is the local scope: the method _jspService() where all the work of the JSP is done.  This acts as a normal method and is where all the sciptlet code goes.
    When you use jsp:useBean you are creating two references to a new String object. One in the local scope accessible through <%= str %> and the other in the session scope.
    When you do <% str = "hello"; %> you are changing the local str variable to reference the String "hello" (this is equivalant to doing <% str = new String("hello"); %>). Only the local reference is changed, not the second reference in session.
    If you want the change to take affect, then you will have to store the new value in session with the same name:
    <% session.setAttribute("str", str); %>

  • To create an instance class Bean

    Interested in knowing to create an
    instance of class which extends TieDocument.
    The required values to be given to the
    constructur arguments.
    public Myclass extends Tiedocument
    public MyClass(LibrarySession ifs, java.lang.Long id,
    java.lang.Long classId, S_LibraryObjectData data)
    throws IfsException {
    super(ifs,id,classId,data);}
    What should be the values to be given to the
    classId,Id,S_LibraryObjectData.
    Looking forward for your reponses.

    Here is an example
    package ifs.demo.typeDefinition;
    import oracle.ifs.beans.TieDocument;
    import oracle.ifs.beans.LibrarySession;
    import oracle.ifs.server.S_LibraryObjectData;
    import oracle.ifs.common.IfsException;
    public class SimpleImage extends TieDocument
    public SimpleImage(LibrarySession ifs,
    java.lang.Long id,
    java.lang.Long classId,
    S_LibraryObjectData data)
    throws IfsException
    // Construct a Document object - standard variant.
    super(ifs,id,classId,data);
    null

  • Scheduled class, bean, mbean?

    Ok. I wrote an app a long time ago that would just call a java class that had a main in it. I was run off of a cron job. It was pretty simple.
    I dont know that newer technologies out there that can schedule a class, or a bean, or whatever to run. Here is what I need to do:
    I am basically doing a syncronization between different databases. I will call them database1, database2, and database3.
    In database1 I have these proposal id's associate with a proposal no doubt. Sometimes for some reason the data is not always sent to the other database, or sometimes the datachanges. So what I am going to do is.
    first: in database1 get all the proposal id that do not have a document number associated with it. resultset1. -- currently 247
    second: compare those proposal ids to the ones in database2. - resultset - 136.
    now if the resultset2 has a document number associate with it, then update database1.
    third: create a report of
    all proposal id's missing a document  number. database1 - this is where it originates
    all matching proposal ids for database1, and database2
    all proposal ids that were updated in database1, and
    all proposal ids that still need to be updated.
    fourth: place the report in a public folder on the network.Right now we want a scheduled job that will run nightly, but I have a feeling that they will want to go in later, and just run it when they want with some modified data in the query. such as a between date, or certain flags?
    anyway - what do you think would be best to run an app like this, and have it scheduled.
    thanks in advance
    orozcom

    I've done a ton of this and the best way for me is what you've done.......write a java class, and call it from cron....wrap it in a shell to make it easy for anyone to run.
    Alternately, you can create a TimerTask inside your class and just kick it off like a daemon. That's not great since there are some leaks depending on the java implementation. HP is very bad about long running (more than 2 day) java processes.
    Regards,
    Ken

  • Inheritence / Aggregates / Class / Bean question

    Hi all, I'm wondering if anybody has tried/succeeded in the following:
    We have a User bean and a User class which we would like to map to one DB table with an aggregate. The user must be available un-aggregated in the mapping workbench for use by other classes which do not require the bean wrapper, so we created a ToplinkUser extending from User, which we turn on aggregation for. The bean then contains a value holder interface attribute dataObject, which we map TopLinkUser [using aggregation as said above].
    Potential issues:
    1) The plain User needs a PK mapping in the DB table, which then gets inherited by ToplinkUser, so the bean ends up with 2 writable PK mappings. The bean mapping must be writable to allow for sequencing.
    2) The User has a many to many Roles mapping which gets inherited by ToplinkUser and shows up on the list of fields that must be mapped in the aggregate usage inside the bean. Is it valid to point this back to the PK?
    Thanks in advance for any thoughts, tips, ideas, or someone who already knows it isn't possible.
    - Jesse

    1 - I'm not sure I follow the issue -- If you have inheritance setup on the descriptor, the mappings should not be duplicated in the subclass. You can override the super class mapping by right-clicking on the descriptor, and setting the visability on "Map inherited attributes".
    2 - It shouldn't have to be mapped, if there is a little "up arrow" on the mapping, that means it's inherited and mapped in the superclass.
    At runtime TopLink checks a descriptor for a mapping, and if it can't find it, if there is inheritance, it goes to the "super descriptor".
    - Don

  • Include jsp versus seperate class/bean versus taglib

    Hi friends,
    I am working on Servlet/JSP project. There are large no. of jsp pages. A common set of methods get repeated in all the jsp pages. Now my concen is to separate out the methods in a file and then use it in jsp page.
    Kindly suggest me the right path to follow, taking into consideration that we take up the optimized solution and performance-wise also feasible.
    Whether I should go for
    1. Using 'include jsp'
    2. using 'taglib'
    3. creating a seperate utility class with the required methods and 'import' it in the JSP pages.
    Kindly reply ASAP.
    Thanks in advance.
    Regards.

    I would suggest you should go for user defined tags.
    This would ensure that the business functionality is isolated from your web objects and it would be modular to maintain.
    Using simple classes will add java code to your JSP pages, which makes them less readable.
    Apart from that implicit object creation by the Servlet/JSP engine(which are instantiating and garbage collecting the taglib objects) will be more efficient.
    Hope this helps
    regards
    Ravi

  • Can't find class for beans in JSP

    Hi there,
    I have a bean.jsp with the following line:
    <%@ page import="Exercise.bean" %>
    I have the class bean.class saved under
    %CATALINA_HOME%/webapps/ROOT/WEB-INF/classes/Exercise.
    The bean.jsp is saved under %CATALINA_HOME%/webapps/ROOT/WEB-INF.
    Compiler error is: package Exercise does not exist.
    Pls advice. thanks.

    have you put:
    package Exercise;
    as the first line in your bean?

  • Validating a method object whether it is a bean class method

    I have a class that is loaded dynamically using URLClassLoader. It is required to validate whether it is a valid bean class' method. i.e. if it is set method, it should start with <set>xxx and if it is get method, it should be like <get>xxx or <is>xxx. I dont want to make it with if conditions and I believe there should be a way to validate if that class satisfies java bean naming specification ( for class/method). Any help is much appreciated.

    kajbj  wrote:
    How would you be able to verify that? Beans can have other methods as well. Well.. in my case, I want to ensure that that does not contain "other methods" and only getters/setters. It should be just a bean and nothing more. There could be cases when a setter method is written like "setTablename" ( note: camel case missing).
    I prefer to use this one.
    public class Bean {
        String tableName;
        public String getTableName() {
            return tableName;
        public void setTableName(String tableName) {
            this.tableName = tableName;
    try {
         BeanInfo info = Introspector.getBeanInfo( Bean.class );
         PropertyDescriptor[] pd  = info.getPropertyDescriptors();
         for (int i=0;i<pd.length;i++) {
              System.out.println( pd.getName() +","+pd[i].getReadMethod());
    if(pd[i].getReadMethod()==null) {
    throw new Exception("Not a bean");
    } catch (Exception e) {
    e.printStackTrace();
    }This code works well, when 1. members not in camel case,
    2. methods not in camel case. But when it comes to method , it throws exception for public String getTablename() {
    return tableName;
    }But it doesnt throw exception for public String gettableName() {
    return tableName;
    } I predicted exception here. Correct me If I am wrong.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • What is the better way to open and close connection in bean

    Hello, may i ask about the best way to open and close the connection?
    At the first, the connection code is store in Conn class bean. The JSP page will call a method in Process bean to process the query and update of database. the Process bean is using th Conn to connect to database.
    In my process bean, it have a method for each type of sql like select, insert, update, and delete for each tables. Each method will call the Conn to open and close the connection. The jsp page can simply call a method retrieve or update records.
    However, when calling the processUpdate method, it is a method that update a group of tables base on the query result of another group of tables and calculation. If I calling the query method in the same bean file, it will open and close the connection many times (more than 1000 times). After open and close the connection several times, the connection to mySQL will be fail.
    Currently, i include 2 method in Process that is only calling the Conn to open the connection and close connection. When calling the openConnection method, it will also set the boolean connected in the class to true and call Conn to open connection. When calling the closeConnection method, it will also set the boolean connected in the class to false and call Conn to close connection.
    After that, i add some change to the query method which is when the connected is false, it will open the connection by calling the Conn and close the connection themself. If the connected is true, it will not call the Conn to open and close the connection because it already connected to the database.
    Now, i when i calling the query method in jsp, it can open the connection and close the connection individually. When i call the processUpdate in the jsp, this method will calling the openConnection before calling the query and calling closeConnection at the end. It not only faster the process(less open and close), it also no cause the connect to mySQL fail error again. However, it also make the coding in the bean file more longer and complex.
    Is there have any better solution?

    Use connection pooling. This will put the connection management in the hands of the webserver, not your code. Check out this post:
    http://forum.java.sun.com/thread.jspa?threadID=741788&messageID=4252932#4252932

  • How can i display the result of java class in InputText ?

    Hi all,
    How can i get the result of java class to InputText Or OutputText ???
    also can every one in the forum give me road map for dealing with java in oracle adf because i'm beginner in oracle adf
    i saw some samples in oracle adf corner but it's difficult for me.

    User,
    Always mention your JDev version, technologies used and clear usecase description (read through this announcement : https://forums.oracle.com/forums/ann.jspa?annID=56)
    How can i get the result of java class to InputText Or OutputText ???Can you elaborate on your requirement? Do you mean the return value of a method in a class as output text? Or an attribute in your class (bean?) as text field?
    -Arun

  • How do i create objects of ordinary Classes from a javabean

    I want to create a class Person below that I want to create an object from in my javabeans.
    Look below Person class definition for continuation.
    package data;
    public class Person
    private String name;
    public Person()
    name = "No name yet.";
    public Person(String initialName)
    name = initialName;
    public void setName(String newName)
    name = newName;
    public String getName()
    return name;
    public void writeOutput()
    System.out.println("Name: " + name);
    public boolean sameName(Person otherPerson)
    return (this.name.equalsIgnoreCase(otherPerson.name));
    I run this bean class in the WEB-INF/classes/data folder creating a Person object in the deal() method below
    When I compile the class it seems to fail. It does not recognise the Person class. Can you help me with a description of what to do to call
    ordinary class objects from javabean class definitions.
    What directories should the simple classes be put and what should I include in the javabean to be able to access them?
    package data;
    import java.sql.*;
    import data.*;
    public class Bean
    { private Connection databaseConnection ;
    // private Person p;
    public Bean()
    super();
    public boolean connect() throws ClassNotFoundException, SQLException
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String sourceURL = "jdbc:odbc:robjsp";
    databaseConnection = DriverManager.getConnection(sourceURL);
    return true;
    public ResultSet execquery(String restrict) throws SQLException
    Statement statement = databaseConnection.createStatement();
    String full = "SELECT customerid,CITY,Address from customers " + restrict;
    ResultSet authorNames = statement.executeQuery(full);
    return (authorNames ==null ) ? null : authorNames;
    public String deal() throws SQLException
    {  Person p = new Person();
    p.setName("Roberto");
    return p.getName();
    }

    There is no "Copy File" function in Lightroom.
    Lightroom was designed to eliminate the need to make duplicate copies of files. The organizational tools in Lightroom allow you to have one file categorized in many ways, you can assign multiple keywords to the photos (for example: Winery, Finger Lakes, Fall Foliage, Jessica). Similarly, you can have a file categorized in multiple Lightroom collections at the same time, all without making a copy of the photo. The benefit of this is that you don't need to make multiple copies of each photo, one copy suffices, and thus disk space is saved; and furthermore if you should edit a photo or add metadata, you only need to do this once, and the photo's appearance, or the photo's metadata is changed, and visible to you no matter how you choose to access the photo (pick any keyword or any collection and you will see the change)

  • How to use Classes stored in "Classes" folder in JSP with tomcat ?

    Hello friends
    im using tomcat as server and MySQL as a Backend. now i am using the date calculation in Diff.class files which i have stored in catalina_home/webapps/prj_dev/Prj_files/classes/diff/DIff.class.
    now i am getting error that :
    Generated servlet error:
    Only a type can be imported. diff.Diff resolves to a package
    wht i have to do ?

    I don't include the "classes" word in my import anymore.. Waa.. I'm going nuts.. T.T
    Now, I'm trying to use the class through useBean..
    this is how my application looks like:
    /webapps
    -----/hangman-jsp
    ------------index.jsp
    ------------/WEB-INF
    -------------------web.xml
    -------------------MysteryPhrase.java
    -------------------/classes
    ---------------------------/beans
    ----------------------------------MysteryPhrase.class
    -----------/images
    -------------------hangman.gif
    This is what is in my MysteryPhrase:
    package beans;
    import java.lang.String;
    import java.lang.StringBuffer;
    public class MysteryPhrase {
         private String answer;
         private StringBuffer mysteryPhrase;
         private int guesses;
         private char[] alphabet;
         public MysteryPhrase () {
         this.alphabet = new char[26];
    public void setMysteryPhrase (String mysteryPhrase) {
         this.answer = mysteryPhrase;
         this.mysteryPhrase = new StringBuffer(mysteryPhrase.length());
         for (int i = 0; i < mysteryPhrase.length(); i++) {
              this.mysteryPhrase.setCharAt(i, '_');
    public void setGuess (char guess) {
         for (int i = 0; i < answer.length(); i++) {
              if (answer.charAt(i) == guess) {
                   mysteryPhrase.setCharAt(i, guess);
         guesses++;
    public String getMysteryPhrase () {
         return mysteryPhrase.toString();
    public String getAnswer () {
         return answer;
    public int getGuesses () {
         return guesses;
    This is what is in my index.jsp (It is not yet finished..I just started..)
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <jsp:useBean id="phrase" class="beans.MysteryPhrase"/>
    <jsp:setProperty name="phrase" property="MysteryPhrase" value="Hello!"/>
    <html>
         <head>
              <title>JSP/JSTL Implementation of Hangman</title>
              <style type="text/css">
                   div {
                        color: white;
                        background-color: gray;
                        position: absolute;
                        border-style: solid;
                        border-width: thin;
                        width: 20%;
                        height: 30%;
                        text-align: center;
                   #guessBoard {
                        top: 28%;
                        left: 42%
                   #mysteryPhraseBoard {
                        top: 50%;
                        left: 25%;
                        z-index: 2;
                   #statisticsBoard {
                        top: 57%;
                        left: 58%;
                        z-index: 2;
                   #categoryBoard {
                        top: 23%;
                        left: 10%
                   #hangman {
                        top: 7%;
                        left: 70%;
                   #char {
                        width: 20px;
                   body {
                        background-color: black;
              </style>
         </head>
         <body>
              <div id="categoryBoard">
                   <form method="post">
                        Please choose a category:
                        <select name="category">
                             <option>Category 1</option>
                             <option>Category 2</option>
                             <option>Category 3</option>
                             <option>Category 4</option>
                             <option>Category 5</option>
                             <option>Category 6</option>
                             <option>Category 7</option>
                             <option>Category 8</option>
                        </select>
                        <input type="submit" value="Change"/>
                   </form>
              </div>
              <div id="mysteryPhraseBoard">
                   The mystery phrase is
              </div>
              <div id="guessBoard">
                   <form method="post">
                        Enter a letter: <input id="char" type="text" name="letter"/>
                        or
                        Enter a word: <input type="text" name="word"/>
                        <input type="submit" value="Guess"/>
                   </form>
              </div>
              <div id="statisticsBoard">
                   Guesses: 0
                   Remaining Letters: 8
              </div>
              <div id="hangman">
                   <img src="images/hangman.gif"/>
              </div>
         </body>
    </html>

  • Problem in using java bean with jsp

    Hi,
    This is my code and i get this error. Not able to trace the mistake.
    bean.html
    <html>
    <head>
    <meta http-equiv="Content-Language" content="en-us">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Fname</title>
    </head>
    <body>
    <form method="POST" action="http://localhost:8080/beanjsp.jsp">
         <p>Fname: <input type="text" name="T1" size="20"></p>
         <p>Lname: <input type="text" name="T2" size="20"></p>
         <p> </p>
         <p> </p>
         <p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
    </form>
    </body>
    </html>
    beanjsp.jsp
    <jsp:useBean id="bean" class="beans.FirstBean" scope="application" />
    <jsp:setProperty name="bean" property="fname" param="T1" />
    <jsp:setProperty name="bean" property="lname" param="T2" />
    THE FIRST NAME IS <%=bean.getFname() %>
    THE LAST NAME IS <%=bean.getLname() %>
    FirstBean.java
    //CREATING A BEAN
    package beans;
    import java.io.*;
    public class FirstBean
         private String fname;
         private String lname;
         FirstBean()
              fname="";
              lname="";
         public void setFname(String fn)
              fname=fn;
         public void setLname(String ln)
              lname=ln;
         public String getFname()
              return fname;
    public String getLname()
              return lname;
    error report
    org.apache.jasper.JasperException: /beanjsp.jsp(2,0) The value for the useBean class attribute beans.FirstBean 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:1223)
         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:3270)
         org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:189)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)I have placed the beans package folder containing FirstBean.class inside classes folder of ROOT directory.
    I don't know what s wrong with my code :( ... Plz help asap.
    Thanks,
    Akshatha

    I have placed the beans package folder containing FirstBean.class >inside classes folder of ROOT directory.Place it in the WEB-INF/classes folder
    ram.

  • Accesing image files in java beans

    hi all
    I am developing an application which needs to access images files put in image folder in java bean file.
    I tried a lot by using different methods and failed always, except in case of absolute path which I dont want to use.
    My directory structure is as below
    /Web-apps
    /MyApp
    index.html
    myjsp.jsp
    /Images
    img1.png
    /WEB-INF
    /classes
    /beans
    GraphBean.java
    In GraphBean.java I have the code
             ImageIcon imageIcon = null;
             imageIcon = new ImageIcon("../image/img1.PNG");Cureently the path is worng and the image cant be displayed.
    I want to know what path I should give to get the image img1.png.
    Thanks in advance
    Aniket

    The disk file system knows nothing about the application which is asking for the file. You should always use absolute file system paths. In this case you can use ServletContext#getRealPath() to convert a relative web URL to an absolute filesystem path. Then use this in ImageIcon.

Maybe you are looking for

  • CUPC 8.6 Desk phone control

    Currently running CUCM 8.6 along with CUPS 8.6.  Currently we are able to get the softphone to register and make calls, but we can not get deskphone control.  When we look at server health on the CUPC client, we just keep seeing "Connecting" and the

  • Glitches in the FCP 5 installed in a MAC Mini G4 1.42Ghz, 512RAM

    I recently upgraded my Mac Mini's memory to 512 from the standard 256 it came with. I have installed FCP 5 on it. When I start doing my editing the clips don't play smoothly. They keep freezing up and then the audio continues and the clip catches up

  • Sharing an external Hard Drive connected to Time Capsule

    Hi all, I have my time capsule set and running now for a few weeks. I have an external hard drive which want to connect it to TC and share it over the network. I connected the HD to the TC and restarted the machine. But I'm not sure why is not showin

  • Should I organise on import or later?

    At the moment most of my photos are not in iPhoto, they are sort organised in folders by date/events, eg Holiday 10, Xmas 11 etc I have recently joined Crashplan, although I also use Time Machine. So at the moment CrashPlan isn't backing up them fold

  • Count Specific Value in Column as a Total

    I am using Oracle 10g, In my worksheet i have created column using Decode Function.I would like to count Flag='Y'(not using group sort). Could anybody help me on this problem Eg: Entered Employment At Exit Y Y N Y N Y Y Total = 5 Thanks, Vikram