Problem in accessing object using Expression Language

Hello All,
Im using Tomcat 5.5 and I am learning Expression language.Im using one servlet page as login.java i.e,
package common;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import Database.DatabaseObject;
import valueobjects.login1;
public class login extends HttpServlet {
     public static final long serialVersionUID = 8707690322213556804l;
     public void doPost(HttpServletRequest req, HttpServletResponse res) {
          String name = req.getParameter("username");
          String password = req.getParameter("password");
          RequestDispatcher dispatch = null;
          ResultSet rs=null;
          Statement st=null;
          login1 log=null;
          Connection con = null;
          String sql=null;
          try
          con=new DatabaseObject().getConnection();
          st = con.createStatement();
          sql="select * from login";
          System.out.println(sql);
          rs=st.executeQuery(sql);
          while(rs.next())
               log=new login1(rs.getString("User_Name"),rs.getString("user_Password"));
          req.setAttribute("login",log);
          req.setAttribute("username",name);
          req.setAttribute("password",password);
          dispatch = req.getRequestDispatcher("/jsps/el.jsp");
          dispatch.forward(req, res);
          catch(Exception e)
               e.printStackTrace();
That login1 customized object is set as ,
package valueobjects;
public class login1{
     String Name;
     String Password;
     public login1(String name, String password) {
          super();
          // TODO Auto-generated constructor stub
          Name = name;
          Password = password;
     public String getName() {
          return Name;
     public void setName(String name) {
          this.Name = name;
     public String getPassword() {
          return Password;
     public void setPassword(String password) {
          this.Password = password;
then im using one jsp as el.jsp that is,
<%@ page isELIgnored="false"%>
<%@ page import = "java.util.*,valueobject.*"%>
<html>
<jsp:useBean id="login" class="valueobjects.login1">
<jsp:setProperty name="login" property="name" value="username"/>
<jsp:setProperty name="login" property="password" value="password"/>
</jsp:useBean>
<body>
     <center>
     username=${login.Name}<br><br>
     </center>
</body>
</html>
but when i execute this code it is giving error as
/jsps/el.jsp(4,0) The value for the useBean class attribute valueobjects.login1 is invalid.
But that login1.java is in correct package that is valueobjects.but im not getting why it is giving such error.Plz help me.

hi
to use java bean u MUST follow the two conviosions:
1. the class u want to make a bean from it must have no-argument constructor
2. u must provide setter and getter for every instance variable , the name of instance varible must begin with small letter and its setter and getter must be like setXxx() and getXxx()
the correct bean is :
package valueobjects;
     public class login1{
     String name;
     String password;
     public String getName()
               return name;
     public void setName(String name)
               this.name = name;
     public String getPassword()
                return password;
     public void setPassword(String password)
                this.password = password;
     }where is my duke's $ ???

Similar Messages

  • Can't access object using "id" or "name" if created with actionscript

    How can you register an instance of an object with actionscript so that it's id or name value is accessible?
    I included a simple example where a Button is created using mxml and in the same way it is created using actionscript.  The actionscript object is inaccessible using it's "id" and "name" property.
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
                   creationComplete="application1_creationCompleteHandler(event)">
        <fx:Script>
            <![CDATA[
                import mx.events.FlexEvent;
                protected function application1_creationCompleteHandler(event:FlexEvent):void
                    import spark.components.Button;
                    var asBtn:Button = new Button();
                    asBtn.label = "actionscript";
                    asBtn.x = 200;
                    asBtn.id = "asButton";
                    asBtn.name = "asButtonName";
                    addElement(asBtn);
                    trace("mxmlButton="+this["mxmlButton"].label); // returns: mxml  label
                    //trace("mxmlButton="+this["asButton"].label); // returns runtime error: ReferenceError: Error #1069: Property asButton not found on TestId and there is no default value.
                    //trace("mxmlButton="+this["asButtonName"].label); // returns runtime error: ReferenceError: Error #1069: Property asButtonName not found on TestId and there is no default value.
            ]]>
        </fx:Script>
        <s:Button
            id="mxmlButton"
            label="mxml label"
            alpha="0.8"/>
    </s:Application>

    Hi Dan,
    It is a very rare occurrence when I miss not being able to access an object (object property, really) using the ["name"] notation for objects created using actionscript.
    In MXML the compiler is conveniently adding an attribute to the class with the same name as the id, so you can conveniently refer to it using the [] notation. While we explicitly specify an application container to use, the MXML compiler creates a custom container which is a derivative of the base container and to that it adds properties for the children declared in MXML. I guess it also effectively calls "addElement" for us when  the container is being constructed.
    Your example assumes that using "addElement" to add the button to the application container is the same as declaring a variable (ie property ). It isn't, so there's no point in looking for an property of the name "as3Button" using the [] notation, because it doesn't exist. The container is managing a collection of children in it's display list and that's not the same as being accessible as properties of the container.
    Generally speaking, accessing properties using the ["name"] syntax isn't necessary.
    Paul
    [edit: you may wonder why "addElement" doesn't conveniently also add the "id" attribute to be an property of the container class. Unfortunately, it can't because the container class would need to be dynamic and it's not. A further complication would be that adding properties at runtime would invite naming clashes at runtime with associated mayhem. MXML can do this because the compiler generates the class and can trap name duplication at compile time.
    Great question, BTW.
    -last edit changed my "attributes" to be "properties" in line with Adobe's terminology]

  • Problem while accessing object in remote database

    Hi All,
    We have a procedure "UPDATE_CONV_DETAILS" created in the remote databse in the "apps" schema. The synonym for the procedure is created in the billing schema(present in the remote database). A dblink is created the local database through which we are tring to access the remote object "UPDATE_CONV_DETAILS".
    Dblink script:
    create public database link PRE_TO_CEL
    connect to BILLING
    identified by BILLING
    using 'MAP1';
    When trying to access the object from the local machine using the schema name.object_name it works fine:
    SQL> DESC APPS.UPDATE_CONV_DETAILS@PRE_TO_CEL
    PROCEDURE APPS.UPDATE_CONV_DETAILS@PRE_TO_CEL
    Argument Name Type In/Out Default?
    IN_MOBILE VARCHAR2 IN
    IN_SERVICE_CODE VARCHAR2 IN
    IN_STATUS VARCHAR2 IN
    OUT_ERROR_CODE NUMBER OUT
    But when trying the access the same object using the synonym_name it gives the error:
    SQL> DESC UPDATE_CONV_DETAILS@PRE_TO_CEL
    ERROR:
    ORA-04043: object APPS.UPDATE_CONV_DETAILS does not exist
    Regards,
    Kirti

    You have two schema.
    apps
    billing
    both reside in remote database.
    there on procedure and on procedure u create one synonym and u want to access it.
    ur remote database name is "map1"
    on ur local database ur create one dblink to access remote database.
    ORA-04043: object string does not exist
    Cause: An object name was specified that was not recognized by the system. There are several possible causes:
    - An invalid name for a table, view, sequence, procedure, function, package, or package body was entered. Since the system could not recognize the invalid name, it responded with the message that the named object does not exist.
    - An attempt was made to rename an index or a cluster, or some other object that cannot be renamed.
    Action: Check the spelling of the named object and rerun the code. (Valid names of tables, views, functions, etc. can be listed by querying the data dictionary.)

  • How to check arraylist size greater than 1 using expression language in jsp

    I want to remove the scripplet in jsp, so i am using jstl tags with expression language in it.
    My scripplet is
    <% if (arraylist.size() > 1) {
    ---do something ----
    %>
    i wanted to change this to
    <c:if test="${ somecondition }">
    ---do something ----
    </c:if>
    here "somecondition" is exactly i need to check whether my arraylist size is greater than 1.
    so please can anyone help me how can i do that.

    If you do not mind, you can create a function and package it into a tag library of your own. Then you can use the function just as the existing expressions language construct. You may take a look at the article use functions in jsp expression language.

  • Interlace problems with moving objects using iDVD

    I had an MP4 file (created by a 3rd party) from a Hi-8 analog tape which has some interlace artifacts on moving images (left image of boy) but not too bad. When the MP4 files was imported into iMovie 11 the interlace artifacts smoothed somewhat - that was OK (right image of boy). The camera was still and the boy was moving.  Vertical lines on stationary objects are OK in all images. These are screen captures from the Mac of the mp4 played through quicktime and the same file imported into iMovie 11 and played.  I paused both to take the screen capture.
    The completed project in iMovie 11 looked OK when previewed prior to rendering. These are 20 year old videos so my expections were being met.   I rendered the project with iDVD to the hard drive first and then to a DVD with the same poor imaging result on the moving object.  I am using a new Macbook Pro I bought in early January which came with iMovie 11 and iDVD  Ver 7.1.2 (1158). Running Mac OS X 10.7.3  Macbook Pro  2.3 Ghz Corei7   8GB 1333 Mhz DDR3.
    I couldn't screen capture from the MAC DVD player screen to illustrate the poor result (got a checkerboard screen) so I took a photo of the screen and imported that (below).  The moving boy on the left is from an  iMovie 11 screen capture, the image on the right is the moving boy from the rendered DVD I paused on the Mac (and took a pic of).
    Below a close up of the poorly rendered moving boy viewed on the resultant DVD.  This translates into a horrible rendition of any quick moving object.  It happens with any moving image - i.e. a pan across a room with straight vertical lines like edges of a wall will show as serrated and poorly rendered edge. I used a trial version of the Daniusoft DVD creator with the same result!  I am at a loss on how to resolve this issue.  Any thoughts out there??
    I had previously used Pinnacle Studios on my old XP PC which worked great on other tape's Mpeg files and created great DVD's (never had an interlace problem) ... until my computer died .....  so I figured Apple and associated software should be at least equal if not a superior product.   Now I'm not too sure!

    I had an MP4 file (created by a 3rd party) from a Hi-8 analog tape which has some interlace artifacts on moving images (left image of boy) but not too bad. When the MP4 files was imported into iMovie 11 the interlace artifacts smoothed somewhat - that was OK (right image of boy). The camera was still and the boy was moving.  Vertical lines on stationary objects are OK in all images. These are screen captures from the Mac of the mp4 played through quicktime and the same file imported into iMovie 11 and played.  I paused both to take the screen capture.
    The completed project in iMovie 11 looked OK when previewed prior to rendering. These are 20 year old videos so my expections were being met.   I rendered the project with iDVD to the hard drive first and then to a DVD with the same poor imaging result on the moving object.  I am using a new Macbook Pro I bought in early January which came with iMovie 11 and iDVD  Ver 7.1.2 (1158). Running Mac OS X 10.7.3  Macbook Pro  2.3 Ghz Corei7   8GB 1333 Mhz DDR3.
    I couldn't screen capture from the MAC DVD player screen to illustrate the poor result (got a checkerboard screen) so I took a photo of the screen and imported that (below).  The moving boy on the left is from an  iMovie 11 screen capture, the image on the right is the moving boy from the rendered DVD I paused on the Mac (and took a pic of).
    Below a close up of the poorly rendered moving boy viewed on the resultant DVD.  This translates into a horrible rendition of any quick moving object.  It happens with any moving image - i.e. a pan across a room with straight vertical lines like edges of a wall will show as serrated and poorly rendered edge. I used a trial version of the Daniusoft DVD creator with the same result!  I am at a loss on how to resolve this issue.  Any thoughts out there??
    I had previously used Pinnacle Studios on my old XP PC which worked great on other tape's Mpeg files and created great DVD's (never had an interlace problem) ... until my computer died .....  so I figured Apple and associated software should be at least equal if not a superior product.   Now I'm not too sure!

  • Problem in accessing NFS using WebNFS.

    Hi,
    We are trying to access an NFS area from our web application which is deployed in Weblogic server by the use of WebNFS api.
    Both our weblogic server and NFS area present in a Solaris box(5.8 release).
    For NFS configuration the entries made to the config files as
    /etc/dfs/sharetab
         /ics_data - nfs root=anon
    /etc/dfs/dfstab
         share -F nfs -o root=anon /ics_data
    For reference, the following commands do list the exported file system as
    > df -k | grep ics
    /dev/dsk/c1t13d0s6 1026367 12 964773 1% /ics_data
    > /usr/sbin/showmount -e
    export list for sunbom4:
    /ics_data (everyone)
    Also the nfs daemons are running
    > ps -ef | grep nfs
    root 9599 1 0 16:05:58 ? 0:00 /usr/lib/nfs/mountd
    root 9601 1 0 16:05:58 ? 0:00 /usr/lib/nfs/nfsd -a 16
    root 25505 1 0 15:14:25 ? 0:00 /usr/lib/nfs/lockd
    daemon 25506 1 0 15:14:25 ? 0:00 /usr/lib/nfs/statd
    Our java code as follows
    XFile xfd = new XFile("nfs://[IPAddress]:2049//ics_data");
    System.out.println("xfd.exists() = " + xfd.exists());
    XFile xfd1 = new XFile("nfs://[IPAddress]:2049//ics_data/testFile.txt");
    System.out.println("xfd1.exists() = " + xfd1.exists());The output is
    xfd.exists() = false
    xfd1.exists() = false
    We have confirmed the nfs port by
    cat /etc/services | grep nfsnfsd 2049/udp nfs # NFS server daemon (clts)
    nfsd 2049/tcp nfs # NFS server daemon (cots)
    Though the file actually exists on the specified location, we could not able to get it by using XFile and NFS url. Kindly advice if we are missing out something some where or incase we are taking any wrong approach.

    We have also tried to associate the 'public' file handle with the shared file system by changing the entry in /etc/dfs/dfstab file as
    share -F nfs -o root=anon,public,log /ics_data
    And our java code as
    XFile xfd = new XFile("nfs://[IPAddress]:2049");
    System.out.println("xfd.exists() = " + xfd.exists());
    XFile xfd1 = new XFile("nfs://[IPAddress]:2049//testFile.txt");
    System.out.println("xfd1.exists() = " + xfd1.exists());But the same problem still persists.
    Can any one please help us out to identify the problem?
    Message was edited by:
    Amit.Pol

  • Keychain Services API, problem creating Access Object

    Hello,
    So I am trying to add a keychain and also set an application to have access to this keychain.
    In the SecAccessCreate() you're supposed to pass it a CFStrigRef, which is where I have been having a problem really.
    char myDescriptor[] = "My Application";
    CFStringRef myCFStrRef = CFStringCreateWithCString( NULL, myDescriptor, 0x08000100 );
    Then I pass that to my SecAccessCreate() but I always seem to be getting a segmentation fault.
    I appreciate any help,
    Smerky

    Smerky wrote:
    0x08000100
    Use the constants defined in the header files. They exist because nobody can read this.
    Also be aware that CFString and NSString are toll-free bridged and therefore completely interchangeable.

  • Problem in accessing database using a java class

    Hy Folks,
    I have written a class to retrive data from data base and compiled it.when I said java QueryExample, I am getting the following error message.It is as below.
    E:\>java QueryExample
    Loading JDBC Driver -> oracle.jdbc.driver.OracleDriver
    java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:120)
    at QueryExample.<init>(QueryExample.java:37)
    at QueryExample.main(QueryExample.java:129)
    Creating Statement...
    Exception in thread "main" java.lang.NullPointerException
    at QueryExample.performQuery(QueryExample.java:70)
    at QueryExample.main(QueryExample.java:130)
    Now my question is can I run a jdbc program with out using any application server or webserver.
    If I can , what are all the packeages I have to down load, and how to set their classpath.
    Regards,
    Olive.

    My basic doubght is can we write a class like this.Here I give the sample code that I am using,,,, and using Oracle9i for Windows release 2 (9.2) .
    // QueryExample.java
    import java.sql.DriverManager;
    import java.sql.Connection;
    import java.sql.Statement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    * The following class provides an example of using JDBC to perform a simple
    * query from an Oracle database.
    public class QueryExample {
    final static String driverClass = "oracle.jdbc.driver.OracleDriver";
    final static String connectionURL = "jdbc:oracle:thin:@localhost:1521:O920NT";
    final static String userID = "scott";
    final static String userPassword = "tiger";
    Connection con = null;
    * Construct a QueryExample object. This constructor will create an Oracle
    * database connection.
    public QueryExample() {
    try {
    System.out.print(" Loading JDBC Driver -> " + driverClass + "\n");
    Class.forName(driverClass).newInstance();
    System.out.print(" Connecting to -> " + connectionURL + "\n");
    this.con = DriverManager.getConnection(connectionURL, userID, userPassword);
    System.out.print(" Connected as -> " + userID + "\n");
    } catch (ClassNotFoundException e) {
    e.printStackTrace();
    } catch (InstantiationException e) {
    e.printStackTrace();
    } catch (IllegalAccessException e) {
    e.printStackTrace();
    } catch (SQLException e) {
    e.printStackTrace();
    * Method to perform a simply query from the "emp" table.
    public void performQuery() {
    Statement stmt = null;
    ResultSet rset = null;
    String queryString = "SELECT name, date_of_hire, monthly_salary " +
    "FROM emp " +
    "ORDER BY name";
    try {
    System.out.print(" Creating Statement...\n");
    stmt = con.createStatement ();
    System.out.print(" Opening ResultsSet...\n");
    rset = stmt.executeQuery(queryString);
    int counter = 0;
    while (rset.next()) {
    System.out.println();
    System.out.println(" Row [" + ++counter + "]");
    System.out.println(" ---------------------");
    System.out.println(" Name -> " + rset.getString(1));
    System.out.println(" Date of Hire -> " + rset.getString(2));
    System.out.println(" Monthly Salary -> " + rset.getFloat(3));
    System.out.println();
    System.out.print(" Closing ResultSet...\n");
    rset.close();
    System.out.print(" Closing Statement...\n");
    stmt.close();
    } catch (SQLException e) {
    e.printStackTrace();
    * Close down Oracle connection.
    public void closeConnection() {
    try {
    System.out.print(" Closing Connection...\n");
    con.close();
    } catch (SQLException e) {
    e.printStackTrace();
    * Sole entry point to the class and application.
    * @param args Array of String arguments.
    * @exception java.lang.InterruptedException
    * Thrown from the Thread class.
    public static void main(String[] args)
    throws java.lang.InterruptedException {
    QueryExample qe = new QueryExample();
    qe.performQuery();
    qe.closeConnection();
    }

  • TS1398 problems to access Idisk using my Ipad

    I have access to a Wi-fi internet, but my Ipad can't access the Idisk, even sync with my MacBook. I'm trying to sync the Ipad and Mac using the  app "papars" without success also.
    What is happening? What can I do?

    I suggest you read this recent thread about iDisc, iPad and the Cloud:
    https://discussions.apple.com/thread/3875702?start=0&tstart=0

  • Problem creating Cipher object using getInstance

    Hi all, Can anyone please help me with this? I am using jdk1.4 which has jce. I have put jce.jar jars in classpath. When I create Cipher object like
    Cipher itsocipher1 = Cipher.getInstance("DES");
    it compiles fine but when I exicute it get following error java.lang.NoSuchMethodError at javax.crypto.SunJCE_d.a(DashoA6275) at javax.crypto.SunJCE_d.a(DashoA6275) at javax.crypto.SunJCE_d.verify(DashoA6275) at javax.crypto.SunJCE_b.f(DashoA6275) at javax.crypto.SunJCE_b.<clinit>(DashoA6275) at javax.crypto.Cipher.getInstance(DashoA6275) at EncryptDecrypt.main(EncryptDecrypt.java:26) Please Guide. Thanks.

    Copy the jce provider's jar file ( if using SunJCE, then copy sunjce_provider.jar file) to jre's lib/ext directory.
    You can also see in the java.policy file where the jvm is looking for the jar files.
    grant codeBase "file:${java.home}/lib/ext/*" {
    permission java.security.AllPermission;
    };

  • Accessing Object using mutliple threads

    I created a class that creates 2 threads and both thread calls a method ( not synch..). In the method i create a new object.
    Here is the code for it.
    class ggh{
        public void m1(){
            ss s1= new ss();      // Simple class having 2 fields(int and string) and their getter setters
            System.out.println("S1 for thread #" + Thread.currentThread().getName() + "  ==> " + s1.toString()  );
            if(Thread.currentThread().getName().equals("Thread-0"))  // thread #1
                try {
                    Thread.sleep(1000);      // -------------> 1
                s1.setA(2);                           // --------------> 2
                System.out.println("Settin s1 = null " + Thread.currentThread().getName());
                    s1 = null;                         //  ---------------> 3
                } catch (InterruptedException ex) {
                    ex.printStackTrace();
            System.out.println("s1 a==>" + s1.getA() + "::" + Thread.currentThread().getName() + " :: " + s1.toString());         //----------------> 4
        public static void main(String[] args) {
            final ggh g1 = new ggh();
            Thread t1 = new Thread(){
                public void run(){
                    g1.m1();
            Thread t2 = new Thread(){
               public void run(){
                        g1.m1();
            t1.start();
            t2.start();
    }when i execute this code, my output is totally unpredictable. Here are some of the outputs i got.
    ************** 1 The code creates the same object for both threads
    S1 for thread #Thread-0 ==> vom.cdd.ss@defa1a
    S1 for thread #Thread-1 ==> vom.cdd.ss@defa1a
    s1 a==>1::Thread-1 :: vom.cdd.ss@defa1a
    Settin s1 = null Thread-0
    java.lang.NullPointerException
         at vom.cdd.ggh.m1(ggh.java:39)
         at vom.cdd.ggh$1.run(ggh.java:46)
    ************** 2 objects are different now.
    S1 for thread #Thread-0 ==> vom.cdd.ss@f5da06
    S1 for thread #Thread-1 ==> vom.cdd.ss@defa1a
    s1 a==>1::Thread-1 :: vom.cdd.ss@defa1a
    Settin s1 = null Thread-0
    java.lang.NullPointerException
         at vom.cdd.ggh.m1(ggh.java:39)
         at vom.cdd.ggh$1.run(ggh.java:46)
    ************* 3 [Here nullpointer exception occurs before the null message is printed[/b]
    S1 for thread #Thread-0 ==> vom.cdd.ss@defa1a
    S1 for thread #Thread-1 ==> vom.cdd.ss@defa1a
    s1 a==>1::Thread-1 :: vom.cdd.ss@defa1a
    java.lang.NullPointerException
         at vom.cdd.ggh.m1(ggh.java:39)
         at vom.cdd.ggh$1.run(ggh.java:46)
    Settin s1 = null Thread-0
    So my question here is :
    when such kind of unsynch. access occurs for some method. then does there exists a different object [b]( a new memory is allocated ) for each thread
    or does there exist only one object and each thread has a different reference to it, and the thread can manipulate its properties.
    Or does there exist a different explanation for this kind of behaviour??
    One more thing, i dont wnat the method/a block of code to be synchronized.
    I also have another doubt but willl post it after this one get's cleared.
    Thanks in advance.
    Regards
    Akshat Jain

    2 objects are different nowThey are not different at all. Address can differ at
    each invocation.What do u mean that they are not different at all.
    if they have different object's then obviously their address are different and henc the objects too.
    am i getting this wrong??

  • How to display ArrayList of Vectors using Expression Language in a JSP

    I have added all my values in a vector and this vector is then added to a List. How can I loop through this List, Vector and values in Vector using EL on JSP side. If you have any idea, pl. help with sample code.

    Hi Kavita,
    Well to display each employee information on jsp, you can use following code sceanarion.
    <%
    Iterator it= list.iterator();
    while(it.hasnext()){
       Employee emp=(Employee) it.next();
    %>
    <tr>
    <td><%= emp.getName()%></td>// In the similar fashion you can display other attributes of employee in other td's.
    </tr>
    <%
    }%>Hope this would be helpful to you.
    Regards,
    Gaurav Daga

  • Problem in loading Objects using ObjectInputStream

    Hello,
    This method load data from the secondary memory/
    public void load() throws Exception
    //File dataFile = new File(".\\center.dat");
    //if (dataFile.exists())
    ObjectInputStream in = null;
    in = new ObjectInputStream(new
    FileInputStream("center.dat"));
    System.out.println("Open file for reading");
    if(in == null)
    System.out.println("File does not open correctly");
    //Load courses
    courses = (CourseList)in.readObject();
    System.out.println("Successfully read courses of the system");
    //Load Modules
    modules = (ModuleList)in.readObject();
    System.out.println("Successfully read modules of the system");
    //Load Batches
    batches = (BatchList)in.readObject();
    System.out.println("Successfully read batches of the system");
    //Load Candidates
    candidates = (CandidateList)in.readObject();
    System.out.println("Successfully read candidates of the system");
    in.close();
    System.out.println("Close objects file");
    As i print the message of the exception it print Code excepting
    I get this exception when i call readObject method and i had checked Object of ObjectInputStream i.e. in is not null.
    Please help me

    1) Stick to your thread: http://forum.java.sun.com/thread.jspa?threadID=651247
    2) What's the stack trace?

  • {Expression Language} not working tomcat5 j2se 1.5_beta

    I m new to JSP technology. I m trying to use expression language in my application and it's not letting me do the job.
    simple program
    <head> <body>
    Hi there! 3 + 3 is ${3+3}
    </body></head>
    It just shows " Hi there! 3 + 3 is ${3+3} " as the output. I tried google search. it seems the problem is across many networks like in bea weblogic etc.,
    when i used <%@page isELEnabled="true" > i get an error saying attribute isELEnabled not recognised or something like that. My web.xml hasn't got any setting for jsp so I don't know where the "*.jsp" section is available, just in case that needs any touchup.
    I have installed JSTL under /common/lib dir. but i think this library is not required for using basic EL.
    So, can anyone help me configure my JSP page so that i can use EL tags in them.
    OS: Windows 2000
    Tomcat ver: 5
    J2Se: 1.5 beta

    Hmmm. Looks like I didn't make myself clear enough.
    You still have the declaration DTD for servlet 2.3 at the top of your web.xml.
    To enable EL using Tomcat 5 you only need to do ONE of the following:
    1 - update your web.xml file to have the header for the 2.4 version (note its not a DTD anymore)
    2 - if your web.xml uses the DTD from version 2.3, include the page directive <%@ page isELIgnored="false" %> on any pages
    Basically the rules for executing EL are as follows:
    1 - Is there a directive on the page? If yes, then enable/disable according to the directive.
    2 - Is there an entry in web.xml for handling EL? If yes then enable/disable according to the setting
    3 - Is the web.xml file for the Servlet 2.4 spec? (ie does it start have the version 2.4 header) Yes = enable EL No = disable EL
    The easiest way of enabling EL is updating your web.xml to be compliant with the latest servlet spec.
    Cheers,
    evnafets

  • Reading Objects using NIO

    I having problems reading an object using NIO APIs. I am end creating an Object and pass it through a socket. When I retrieve the data from the input stream within the socket I initialize a ByteBuffer by allocating a length. The problem is that there is NO way of knowing what to allocate that ByteBuffer when reading in the object. Below is within a method that allows me to read information from the socket.
    //Allocate the length ByteBuffer.
    ByteBuffer buffer = ByteBuffer.allocate(1024);
    //Read the data from the SocketChannel....PROBLEM IS WHAT IF I NEED TO DO MULTIPLE READS
    socketChannel.read(buffer);
    ///We will create a byte array from the ByteBuffer.
    byte[] b = buffer.array();
    //ByteArrayInputStream that we will create and put the byte array in.
    ByteArrayInputStream bis = new ByteArrayInputStream(b);
    //ObjectInputStream where we will use the ByteArrayInputStream.
    ObjectInputStream input = new ObjectInputStream(bis);
    //Object that we will read in.
    Object obj = input.readObject();
    //Message that we will end up receiving.     
    Message receivingMsg = null;
    //Once we have our Message we will end up closing the connection.
    bis.close();
    input.close();
    //We will clear the buffer.
    buffer.clear();
    //We will cast the object to a message object so
    //that we can end up sending it through the right
    //routine which will allow us to send a response
    //back to the client. *********SPECIAL Class that will cast our generic object into a Message Object.
    Message receivedFromClient = (Message) obj;
    //we will end up taking that message and returning it.
    Message returningMsg = communicate(receivedFromClient);
    //Here we will end up taking the Message and putting it into the ByteBuffer.          
    ByteBuffer bb = objectToOutputStreamByteBuffer(returningMsg);
    socketChannel.write(bb);
    ----The problem is if I have more data within that Object. I need to re-allocate the ByteBuffer object and read everything on that socket. I tried the following code but I really don't feel it will be optimized the best for performance. I guess my question is that should I even be using NIO in this situation or Blocking IO?
    Again, here is the code that will read multiple data from the socket until it is -1.
    //Here we will read the information we received by first allocating
    //a ByteBuffer object.
    ByteBuffer buffer1 = ByteBuffer.allocate(5);
    ByteBuffer buffer2 = ByteBuffer.allocate(0);
    //We will read the data from this object.
    while ((socketChannel.read(buffer1)) != -1) {
    //We will check the Buffers and then try to recreate a new ByteBuffer that will put the remaining
    //stuff within the buffer. NOT SURE IF THIS IS THE MOST EFFICIENT WAY OF DOING THIS
    //AND ACTUALLY DON'T HAVE THE CODE WORKING CORRECTLY. THIS IS WHERE I
    //NEED HELP ON THE CORRECT WAY TO DO THIS.
         if (buffer1.remaining() < buffer2.remaining()) {
              buffer1.flip();
              buffer2 = ByteBuffer.allocate(buffer1.remaining() + buffer2.remaining());
              System.out.println("tmp 2 Remaining : " + buffer2.remaining());
              //tmp.put(buffer2);
              //buffer2 = tmp;
              System.out.println("Buffer 2 Remaining : " + buffer2.remaining());
         buffer2.put(buffer1);
         buffer1.clear();
    //We will create a byte array from the ByteBuffer.                    
    byte[] b = buffer.array();
    //ByteArrayInputStream that we will create and put the byte array in.
    ByteArrayInputStream bis = new ByteArrayInputStream(b);
    //ObjectInputStream where we will use the ByteArrayInputStream.
    ObjectInputStream input = new ObjectInputStream(bis);
    //Object that we will read in.
    Object obj = input.readObject();
    //Message that we will end up receiving.     
    Message receivingMsg = null;
    //Once we have our Message we will end up closing the connection.
    bis.close();
    input.close();
    //We will clear the buffer.
    buffer2.clear();
    buffer1.clear();
    //We will cast the object to a message object so
    //that we can end up sending it through the right
    //routine which will allow us to send a response
    //back to the client.
    Message receivedFromClient = (Message) obj;
    //we will end up taking that message and returning it.
    Message returningMsg = communicate(receivedFromClient);
    //Here we will end up taking the Message and putting it into the ByteBuffer.          
    ByteBuffer bb = objectToOutputStreamByteBuffer(returningMsg);
    socketChannel.write(bb);
    Any help would be greatly appreciated.

    I use my own InputStream class overriding the two standard read functions read( byte[], index, length ) and read(). When you construct it pass in the channel you are reading from and read from the channel on demand. ie when a call to read comes in you read say 100 bytes from the channel. The call required only 80 so these are consumed and the other 20 are buffered. Another read call is made, this time for 50 bytes but we only have 20 buffered so another read of the channel is needed. It is up to you whether you break the contract of read( byte[], index, length ) to keep reading the channel until the full "length" is available, or handle this in your application code.
    Then because this class is InputStream you can wrap it up inside any stream you like such as the ObjectInputStream and the data will be serialized correctly.

Maybe you are looking for

  • My ipod touch isn't being recognized by itunes ?

    So my ipod wasn't being recognized by itunes so i sent it away to apple to be fixed and they sent me a brand new one but this one isn't being recognized by itunes eitheir? I've uninstalled and re-installed itunes plenty of times, my lead is perfect a

  • Pages to Image conversion

    1.Is there any efficient way of exporting or converting a Pages file to an image file e.g. .jpg? Has anyone built a patch for this or can a script be used. It's very frustrating as we used to use the AW Suite for this conversion. A number of people h

  • Best practice SAP landscape

    Hello all, I would like to know if there is some kind of best practice regarding SAP landscape in a big company. For example is it recommended to have in the landscape a SAP Quality Assurance System open for customizing (transaction SCC4) so that qui

  • FlexConnect (aka H-REAP) and Auto-Anchor functionality

    Hi Board, I never did H-REAP on my wireless deployments. Now, I have an H-REAP (FlexConnect) requirement for branch offices. Also there is the requirement for guest access at the same time. From my understanding those features (FlexConnect and Auto-A

  • Using getCodeBase

    I need to specify the location on my computer of an image I want to load on a JPanel in an applet. The method getImage(getCodeBase(), "npsha.jpg"); must be used I believe. I believe I am having problems with getCodeBaseI() because I am having trouble