Share Java Object Instance between JSP's

Hi@all!
Can i share a Java Object Instance between JSPages?
Example:
Class x
Public Attribute txt
Object creation in x.jsp
set public Attribute txt to "HelloWorld"
goto y.jsp
get value from txt
or...
a global package
thnx for help

Here is a tutorial that explains how to use jsps and javabeans together.
http://www.roseindia.net/jsp/usingbeansinjsp.shtml
Quick question is sounds like you are pretty early in your development phase. Have you considered adopting JSF. You may find it a bit easier.
Regards.

Similar Messages

  • How to communicate (transfer object instance) between to java vm?

    Hello, All
    If possible to transfer object instance straight between two java vm?

    It is possible to copy an object instance from one java application to another. Define it as serializable, and pass it as a parameter to an RMI call.

  • Using Java Objects in my JSP page... objects are in a different directory

    Hi,
    I would like to call and use an object from a JSP page. The java object is in one directory, the jsp is in another. When I call my object, I get a JSP error that says it can't find the object and lists the directory name as part of the file.
    For example, here are my two files:
    /java/MyObject.class
    /web/page.jsp
    When I make the call to new MyObject(), I get an error message saying _web.MyObject cannot be found.  Any ideas on this?
    Thanks!

    Okay, I figured it out. In case anyone else needs it, here is what I needed to do.
    1) I created my object in a package. The JSP page was looking for the object in _dir directory because a package wasn't specified.  I created a subdirectory in one of the directories in my classpath and named it the same thing that the package was named.
    2) Import the package
    3) Make sure all methods in the classes are public, since only public methods can be accessed from outside the package.
    Thanks for the help, it got me going in the right direction.

  • Transient java object instance from jvm through jni?

    Hello, All
    Sometimes I want manage the memory take by object instance,
    for example, If I want to design a cache which cache a huge number object.
    Then, there may two problems:
    1, May occur OutOfMemory error.
    2, I want like to manually reclaim the memory take by the cached object,
    not by gc, because it may take a little time to check the reference for gc.
    Just as you know, there is keyword transient for serialization.
    I want know if some same mechanism for object instance creating or release, managing memory by jni, or by some other way?

    No, since you're not supposed to do that. hence you can't really expect Java to provide the means...
    Maybe you can use classes like WeakReference etc. but that won't bypass GC.

  • Storing values for object instances between runs

    I'm writing a simple 2d game and I'm trying to create an object to handle the information about individual tiles on the board.
    The tile class will handle three pieces of information:
    1. an image to represent the tile
    2. a boolean value (true if the tile can be passed through, false if it blocks movement)
    3. a name to describe the surface (mostly for management purposes - so I can say load("whiteMarble01") instead of using the full directory.)
    I plan to pre-build instances of these so that the tiles can be quickly placed with all their options pre-assigned.
    How would you store this data between runs of the game?
    My first thought was a folder (named whatever the name should be) containing an image file and a text file (which contains all the remaining values to be parsed). I don't think this is very good since the text file would only serve to store the boolean.
    Is there a better way?

    You can also use any of the standard XML APIs or java.beans classes XMLEndcoder and XMLDecoder:
    import java.beans.*;
    import java.io.*;
    import java.util.*;
    public class ExampleBean {
        private String name;
        private int code;
        public void setName(String name) {
            this.name = name;
        public String getName() {
            return name;
        public void setCode(int code) {
            this.code = code;
        public int getCode() {
            return code;
        public ExampleBean() {
        public ExampleBean(String name, int code) {
            setName(name);
            setCode(code);
        @Override public String toString() {
            return "(" + getName() + ", " + getCode() + ")";
        public static void main(String[] args) throws IOException {
            List<ExampleBean> beans = new ArrayList<ExampleBean>();
            beans.add(new ExampleBean("Homer", 40));
            beans.add(new ExampleBean("Marge", 37));
            File file = new File("temp.xml");
            XMLEncoder e = new XMLEncoder(
                new BufferedOutputStream(
                new FileOutputStream(file)));
            e.writeObject(beans);
            e.close();
            XMLDecoder d = new XMLDecoder(
                new BufferedInputStream(
                new FileInputStream(file)));
            System.out.println(d.readObject());
            d.close();
    }temp.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <java version="1.6.0" class="java.beans.XMLDecoder">
    <object class="java.util.ArrayList">
      <void method="add">
       <object class="ExampleBean">
        <void property="code">
         <int>40</int>
        </void>
        <void property="name">
         <string>Homer</string>
        </void>
       </object>
      </void>
      <void method="add">
       <object class="ExampleBean">
        <void property="code">
         <int>37</int>
        </void>
        <void property="name">
         <string>Marge</string>
        </void>
       </object>
      </void>
    </object>
    </java>

  • Accesing java objects in a jsp.

    I've got the following problem: I have a java class that contains a connection to a jdbc database, and several functions that manipulate that database( insert ,delete,select..) I create an instance of this class in a servlet, and I need to be able to access this instance in a jsp, in order to dynamically create the response page based on what it is in the database !
    Any ideas ?

    protected void doGet(HttpServletRequest request, HttpServletResponse response) {
        List<RowObject> rowObjects = yourDAO.list();
        request.setAttribute("rowObjects", rowObjects);
        request.getRequestDispatcher("page.jsp").forward(request, response);
    <table>
        <c:forEach items="${rowObjects}" var="rowObject">
            <tr>
                <td>${rowObject.value1}</td>
                <td>${rowObject.value2}</td>
                <td>${rowObject.value3}</td>
            </tr>
        </c:forEach>
    </table>

  • Share variables between JSP and Classes

    Hello !
    Is there any way to share the same variables between JSP�s and Classes?
    For example...
    I have 20 variables in a JSP page (with values, like constants...) and I want to view their contents inside the classes...
    Is there any way? Maybe a import or something like this...
    Thanks,
    Igor.

    If you search the forums you will find many answers to your questions. You can also try the servlet and JSP short courses listed below;
    Here is lthe link that will take you to the Java.sun.com Tutorial pages.
    http://developer.java.sun.com/developer/onlineTraining/
    Here is a tutorial on Servlets
    http://developer.java.sun.com/developer/onlineTraining/Servlets/Fundamentals/contents.html
    Here is the tutorial on the JSP
    http://developer.java.sun.com/developer/onlineTraining/JSPIntro/contents.html

  • Bug in Java objects not serializable

    I plan to use the latest version TopLink 10.1.3.1.0 with Oracle Database 10g (10.2.x).
    Do I still have to use the “Type Conversion” mapping as I had to do in order to address the reported non-serializable bug exiting in TopLink (9.0.4.5). See the link for the bug description:
    http://www.oracle.com/technology/documentation/1012_solaris/relnotes.1012/relnotes/toplink.htm#CEGEBDEG
    My Java object instance variable is defined as java.sql.Timestamp and the corresponding data type on the Oracle DB is defined as TIMESTAMP(6). Can I use the direct-to-field mapping from now on with new TopLink 10.1.3.1.0 without the serializable issue? If I still have to use the Type Conversion mapping, please help provide some detail about the mapping.
    Many thanks for any help.

    From what I can understand from your reply, I can use the direct-to-field mapping for Java class attribute of java.sql.Timestamp to the Oracle DB 10.2.x data type of TIMESTAMP(6) without any issue of not serializable. Please confirm. Many thanks!
    By the way, I am having the same issue (Java objects not serializable) with Oracle DB 10.1.x when I use the direct-to-field mapping. It seems to me that this is more than the Oracle 9i JDBC driver.
    If I have to do this with TopLink 10.1.3.1.0 + Oracle 10.2.x, I plan to use the Type Conversion with:
    Java class attribute: java.sql.Timestamp
    DB data type: oracle.sql.TIMESTAMP
    Is this the proper way to do it? Please confirm.

  • How to Pass Java Objects between Web Dynpro and Java SAP iViews

    Basically I have an SAP web dynpro iView that I do stuff with and I want to pass an object to another iView which is just a regular Java iView. From what I've read and tried, I can't just stick something in the session object and hope that the Java iView can pull it down the other end. I had a dream that it was possible (seriously).
    Anyway, are there any possible solutions around? Please advice and share you throughts. I will try to dream about it again tonight and see if its really gonna work this time.
    thanks for your help in advance

    There is no easy way you can pass objects other than those supported by express such as String, map, list etc.
    Though not advised, you can create a class with static variables to handle the storage of such java objects during transition between form and workflow. You will need to somehow identify the objects uniquely .

  • How can i have a refrence of a java class object instance in my c++ project

    Hi!
    How can i have a refrence of a java class object instance in my c++ project. Is there a way?

    hahaxia wrote:
    The second question is the big one. The first question is half of the problem of "c++ to java" invocation and access. But the other half which is "java to c++ " invocation and access is still not solved. jni only provide the "java to c++ " DLL invocation Wrong,
    Using JNI your java classes can have methods implemented in C/C++.
    Using JNI you can call java classes.
    There is no other possible interaction between C++ and java, so it does it all.

  • What is the difference between acquiring lock on a CLASS and OBJECT (instance) of that class

    What is the difference between acquiring lock on a CLASS and OBJECT (instance) of that class

    What is the difference between acquiring lock on a CLASS and OBJECT (instance) of that class
    The Java Tutotials has several trails that discuss both implicit and explicit locking, how they work and has code examples.
    The Concurrency trail has the links to the other sections you need to review
    http://docs.oracle.com/javase/tutorial/essential/concurrency/index.html
    The Synchronized Methods and Intrinsic Locks and Synchronization trails discusse Synchronized Methods and Statements
    http://docs.oracle.com/javase/tutorial/essential/concurrency/syncmeth.html
    And the Lock Objects trail begins the coverage of explicit locking techniques.
    http://docs.oracle.com/javase/tutorial/essential/concurrency/newlocks.html

  • What is the difference between object, instance, referance?

    What is the difference between object, instance, referance of a class? write some code for that, that will be easy to understand for me.
    Thank you.

    petes1234 wrote:
    paul.miner wrote:
    You'll get a more useful reply if you ask a better question. As it is, your question is overly broad and vague. I beg to differ. I found it direct and to the point: "Please do my homework".I too found it direct but not like that.
    I translated the request as "I am just starting to learn Java and don't understand any of the basic concepts. Could I please have some code that could maybe explain this concepts more clearly so that I can get a practical sense of them?"
    And the answer is... the tutorial.
    I agree the second sentence reads to you and I (and probably others) as demanding, but I think it's just an ESL issue. He/she at least said thanks.

  • How to reference multiple instances of the same Java object from PL/SQL?

    Dear all,
    I'm experimenting with calling Java from PL/SQL.
    My simple attempts work, which is calling public static [java] methods through PL/SQL wrappers from SQL (and PL/SQL). (See my example code below).
    However it is the limitation of the public static methods that puzzels me.
    I would like to do the following:
    - from PL/SQL (in essence it needs to become a forms app) create one or more objects in the java realm
    - from PL/SQL alter properties of a java object
    - from PL/SQL call methods on a java object
    However I fail to see how I can create multiple instances of an object and reference one particular object in the java realm through public static methods.
    My current solution is the singleton pattern: of said java object I have only 1 copy, so I do not need to know a reference to it.
    I can just assume that there will only ever be 1 of said object.
    But I should be able to make more then 1 instance of an object.
    To make it more specific:
    - suppose I have the object car in the java realm
    - from PL/SQL I want to create a car in the java realm
    - from PL/SQL I need to give it license plates
    - I need to start the engine of a scpecific car
    However if I want more then 1 car then I need to be able to refrence them. How is this done?
    Somehow I need to be able to execute the following in PL/SQL:
    DECLARE
    vMyCar_Porsche CAR;
    vMyCar_Fiat CAR;
    BEGIN
    vMyCar_Porsche = new CAR();
    vMyCar_Fiat = new CAR();
    vMyCar_Porsche.setLicensePlates('FAST');
    vMyCar_Porsche.startEngine();
    vMyCar_Fiat.killEngine();
    END;
    Thanks in advance.
    Best Regards,
    Ruben
    My current example code is the following:
    JAVA:
    ===
    CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED CODAROUL."RMG/BO/RMG_OBJECT" as package RMG.BO;
    public class RMG_OBJECT {
    private static RMG_OBJECT instance = new RMGOBJECT();
    private String rmgObjectNaam;
    private RMG_OBJECT(){
    this.rmgObjectNaam = "NonDetermined";
    public static String GET_RMGOBJECT_NAAM () {
    String toestand = null;
    if (_instance == null) {toestand = "DOES NOT EXIST";} else { toestand = "EXISTS";};
    System.out.println("instance : " + toestand);
    System.out.println("object name is : " + _instance.rmgObjectNaam);
    return _instance.rmgObjectNaam;
    public static Integer SET_RMGOBJECT_NAAM (String IN)
    try
    _instance.rmgObjectNaam = IN;
    return 1;
    catch (Exception e)//catch
    System.out.println("Other Exception: " + e.toString());
    e.printStackTrace();
    return 5;
    } //catch
    PL/SQL Wrapper:
    ==========
    CREATE OR REPLACE FUNCTION CODAROUL.SET_RMGOBJECT_NAAM(NAAM IN VARCHAR2) return NUMBER AS
    LANGUAGE JAVA NAME 'RMG.BO.RMG_OBJECT.SET_RMGOBJECT_NAAM (java.lang.String) return java.lang.Integer';
    Calling from SQL:
    ==========
    CALL dbms_java.set_output(2000);
    select CODAROUL.GET_RMGOBJECT_NAAM() from dual;
    Edited by: RubenS_BE on Apr 6, 2012 5:35 AM
    Edited by: 925945 on Apr 6, 2012 5:41 AM

    You can do this by manually creating a new iterator binding in your binding tab.
    So instead of dragging the VO directly to the page, go to the binding tab, add a new executable iterator binding, and point to that one from your ELs in the page itself.

  • How to create and instance of Java Object from an XML Document.

    Hi,
    How can we use a XML Document to create an instance of Java Object and do vice versa ie from the Java Object creating the XML Document.
    XML Document is available in the form of a String Object.
    Are there helper class available to achieve this.
    I need to do this in a Servlet.
    Regards
    Pramod.

    JAXB is part of JavaSE while Xmlbeans claims full schema support and full infoset fidelity.
    If the standard APIs do all that you need well then use them.

  • Explicity mapping between ActionScript and Java objects for the BlazeDS Messaging Service

    The BlazeDS documentation shows how to explicitly map between ActionScript and Java objects. For example, this works fine for RPC services, e.g.
    import flash.utils.IExternalizable;
    import flash.utils.IDataInput;
    import flash.utils.IDataOutput;
    [Bindable]
    [RemoteClass(alias="javaclass.User")]
    public class User implements IExternalizable {
            public var id : String;
            public var secret : String;
            public function User() {
            public function readExternal(input : IDataInput) : void {
                    id = input.readObject() as String;
            public function writeExternal(output : IDataOutput) : void {
                    output.writeObject(id);
    and
    import java.io.Externalizable;
    import java.io.IOException;
    import java.io.ObjectInput;
    import java.io.ObjectOutput;
    import java.util.HashSet;
    import java.util.Iterator;
    import java.util.Set;
    public class User implements Externalizable {
        protected String id;
        protected String secret;
        public String getId() {
            return id;
        public void setId(String id) {
            this.id = id;
        public String getSecret() {
            return secret;
        public void setSecret(String secret) {
            this.secret = secret;
        public void readExternal(ObjectInput in) throws IOException,
                    ClassNotFoundException {
            id = (String) in.readObject();
        public void writeExternal(ObjectOutput out) throws IOException {
            out.writeObject(id);
    If I called an RPC service that returns a User, the secret is not sent over the wire.  Is it also possible to do this for the messaging service? That is, if I create a custom messaging adapter and use the function below, can I also prevent secret from being sent?
    MessageBroker messageBroker = MessageBroker.getMessageBroker(null);
    AsyncMessage message = new AsyncMessage();
    message.setDestination("MyMessagingService");
    message.setClientId(UUIDUtils.createUUID());
    message.setMessageId(UUIDUtils.createUUID());
    User user = new User();
    user.setId("id");
    user.setSecret("secret");
    message.setBody(user);
    messageBroker.routeMessageToService(message, null);

    Hi Martin. The way that AMF serialization/deserialization works for BlazeDS is the same regardless of which service is being used, so yes that code will work for messaging as well. On the server, the serialization/deserialization of messages happens at the endpoint. For an incoming message for example, the endpoint deserializes the message and then hands it off to the MessageBroker which decides which service/destination to deliver the message to.
    That was a good question. Thanks for asking it. Lots of people are used to doing custom serialization/deserialization with the RPC services (RemoteObject/RemotingService) but I'm not sure everyone realizes they can do this for messaging as well.
    -Alex

Maybe you are looking for

  • How to pass a value to path attribute of jpf:forward at run time.

    Hi all, I have a public variable in my controller and I am getting a value from my jsp and assigning it to that variable. Now the question is how to pass that variable value to path attribute of jpf:forward. @jpf:forward name="success" path="promoLin

  • ITunes 7.7.1 & iPhoto & iPhone sync

    I have a iPhoto Library which I use on multiple computers. The whole library ("iPhoto Library") has been copied to a network drive and I use iPhoto to open this library (instead of the local library in Pictures). When I try to sync some photos into a

  • Why can't I play the games in General Knowledge for Dummies?

    As soon as I click on themed questions or anything (apart from Hangman), the ap closes and I don't know who to contact for a refund of purchase of game.  Tried enquiring through Twitter and then noticed that last tweet from Game Center was in 2012!

  • Message no. XS826

    Hello, I was trying to send BW report from EP to BW Inbox via send option in BW iView.. But for some users i'm getting following error message: Cannot process message, no route from 11001844 to neha.garg Message no. XS826 Diagnosis To continue proces

  • Dual Monitors with Photoshop CS4

    I have twin monitors set up the defualt way whereby they act as two seperate monitors for two seperate applications to be maximized in and such. Basically, what happenes, is if i put Photoshop onto the secondary monitor, and create a new canvas, or h