Painting in Applets using another class

hi all
I am trying the simplest of codes, using another class which paints something on the client area.
when I run it it does draw it on the screen but then disappears or is covered. ne suggestions or reasons why this might be happening...
the code is as follows
package test;
import java.awt.*;
import javax.swing.*;
import java.awt.Graphics2D.*;
import java.awt.geom.*;
public class TestApp1 extends JApplet {
private Container container;
public Rectangle rect;
public CTest test1;
public Graphics g;
public void init()
container=getContentPane();
g=container.getGraphics();
Graphics2D g2=(Graphics2D)g;
test1=new CTest(false,g2);
public void run()
container.add(test1);
public void stop()
public void destroy()
package test;
import javax.swing.*;
import java.awt.Graphics;
import java.awt.*;
public class CTest extends JPanel {
protected
Graphics2D m_graphics;
Rectangle m_PlotRect;          
public
CTest(boolean resizable,Graphics2D g)
m_graphics =g;
m_PlotRect=new Rectangle(150,50,50,50);          
void DrawAxis()
m_graphics.setBackground(Color.white);
m_graphics.setColor(Color.black);
m_graphics.drawRect(
(int)m_PlotRect.getMinX(),
(int)m_PlotRect.getMinY(),
(int)m_PlotRect.getWidth(),
(int)m_PlotRect.getHeight()
public void paint(Graphics g)
super.paint(g);
DrawAxis();
public void paintComponent(Graphics g)
super.paintComponent(g);
DrawAxis();

thanx guys
i could solve the problem. thought its good to share it with every one in case some one else falls for the same trap.
what i did was tried to pass the Graphics object to my CTest class and then painted everything on the basis of that.
this is where the code gets freaky.
the correct way of doing it is not passing the graphics object to the CTest class but use the graphics object passed by the system to the paintcomponent function to do all the painting in the class.
I did that and it works well.
cheers
Deepak

Similar Messages

  • Using a static variable declared in an applet in another class

    Hi guys,
    I created an applet and i want to use one of the static variables declared in teh applet class in another class i have. however i get an error when i try to do that...
    in my Return2 class i try to call the variable infoPanel (declared as a static JPanel in myApplet...myApplet is set up like so:
    public class myApplet extends JApplet implements ActionListener, ListSelectionListener
    here are some of the lines causing a problem in the Return2 class:
    myApplet.infoPanel.removeAll();
    myApplet.infoPanel.add(functionForm2.smgframeold);
    myApplet.infoPanel.validate();
    myApplet.infoPanel.repaint();
    here are some of the errors i get
    dummy/Return2.java [211:1] package myApplet does not exist
    myApplet.infoPanel.removeAll();
    ^
    dummy/Return2.java [212:1] package myApplet does not exist
    myApplet.infoPanel.add(functionForm2.smgframeold);
    ^
    dummy/Return2.java [213:1] package myApplet does not exist
    myApplet.infoPanel.validate();
    ^
    dummy/Return2.java [214:1] package myApplet does not exist
    myApplet.infoPanel.repaint();
    ^
    please help! thanks :)

    I don't declare any packages though....i think it just doesn't recognize myApplet for some reason..
    other errors i got compiling are:
    dummy/Return2.java [82:1] cannot resolve symbol
    symbol : variable myApplet
    location: class Return2
    updateDesc.setString(3, myApplet.staticName);
    I Don't get why i'm getting this error cuase they worked fine when myApplet was a standalone application, not an applet.
    myApplet is in the same folder as Return2 and it compiles properly.

  • Class using another class access

    I'm sure this is not difficult, but finding the answer has been quite elusive for me. I'd like to start simple. I have two classes, Place and Address that look like this:
    public class Address{
       private String street;
       private String town;
      ...some other address stuff
       public void setStreet(String streetname) {
         this.street = streetname;
    public String getStreet() {
         return this.street;
    ...same f or town and others
    }//end of Address class
    Now I have the Place class:
    public class Place {
       private String name;
       private Address address **here begins my questionsI currently have the private address declaration as:
       private Address address = new Address();1. Is this Address address declaration correct, or should it be different?
    2. Do I, create setAddress and getAddress methods in the Place class, and if so, so they just use the object 'address', i.e. 'return address;' ?
    After I understand how to do these two things, I need help in accessing the address parts, like street and town, from a third class, the PlaceTest class which has a 'main' method.
    Thanks in advance for your help.

    Check out this as a for-instance. Here is a sample Address class
        class Address
            private String street;
            private String town;
            private String state;
            private String zip;
            public Address(String street, String town, String state, String zip)
                this.street = street;
                this.town = town;
                this.state = state;
                this.zip = zip;
            public void setStreet(String street)
                this.street = street;
            public String getStreet()
                return street;
            @Override
            public String toString()
                return street + ", " + town + ", " + state + ", " + zip;
        }And here is a Place2 class that uses Address
    class Place2
        private Address address;
        public Place2() {}
        public Place2(Address address)  // <== **** here I'm passing an addresss param
            this.address = address;
        public void setAddress(Address address) // <== **** and here too
            this.address = address;
        @Override
        public String toString()
            return address.toString();
        public static void main(String[] args)
            Place2 myPlace = new Place2(
                new Place2().new Address("100 Main St", "AnyTown", "IL", "60022"));
            System.out.println("My address is: " + myPlace);
            // let's change the address:
            Address address2 = new Place2().new Address("123 First St", "Podunckville", "State of Confusion", "10101");
            // then pass this address to myPlace
            myPlace.setAddress(address2);
            // then show it
            System.out.println("My new address is: " + myPlace);
    }

  • Saving current Applet using AWT classes only

    Hey Guys,
    Can any one please help me out for saving current applet view using AWT and not SWING plese .
    I tried this code pls check if there is any improvement.
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    import java.lang.*;
    import java.net.*;
    import java.awt.Graphics;
    import java.awt.image.BufferedImage;
    import javax.imageio.ImageIO;
    import java.io.*;
    import com.sun.image.codec.jpeg.*;
    public class temp extends Applet implements ActionListener
    Image myImg;
    Button b1;
         public void init()
              myImg = getImage(getCodeBase(),"temp.jpg");
              b1 = new Button("Save");
              add(b1);
              b1.addActionListener(this);
         public void paint(Graphics g)
              g.drawImage(myImg, 5, 10, this);
              g.fillOval(10,10,20,20);
         public void actionPerformed(ActionEvent ev)
              BufferedImage bin = new BufferedImage( 200, 200,BufferedImage.TYPE_INT_RGB );
              Graphics page = bin.getGraphics();
              page.setColor( java.awt.Color.BLUE );
              page.drawString( "BLUE", 100, 100 );
              ImageIO.write( bin, "JPEG", new java.io.File( "Test7.jpeg" ) );
    PLESE HELP ME SOOOON

    Hi ,Thanx for your concern.
    I am the same sayjava but I lost my password dats why the name is changed.
    Now about the querry i have completely changed the coding and have successfully created a new JPEG image .
    Can u please tell me how can I save it I have tried the following coding but it doent seem to work...
    File file = new File("images", "imgOne.jpg");
    FileOutputStream out = new FileOutputStream(file);
    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
    JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi);
    param.setQuality(1.0f, false);
    encoder.setJPEGEncodeParam(param);
    encoder.encode(bi); //bi is the BufferedImage
    Thanks Again.

  • Java class uses another class in a Jar file (How do I make Java see it)?

    I am trying to figure out how do I make Javac see the thinlet.class in the thinlet.jar.
    I have developed an XUL xml interface and a java program that calls the interface shown below:
    //package thinlet.demo;
    import thinlet.*;
    public class UI extends Thinlet
    { public UI () throws Exception {add(parse("UI.xml"));}
    public static void main(String[] args) throws Exception
    { new FrameLauncher("UI", new UI(), 600, 600); }}
    when I do the normal compile, I get an error:
    UI.java:4: cannot find symbol
    symbol: class Thinlet
    public class UI extends Thinlet {
    ^
    UI.java:7: cannot find symbol
    symbol : method parse(java.lang.String)
    location: class thinlet.demo.UI
    add(parse("UI.xml"));
    ^
    UI.java:12: cannot find symbol
    symbol : class FrameLauncher
    location: class thinlet.demo.UI
    new FrameLauncher("UI", new UI(), 600, 600);
    ^
    3 errors
    This thinlet class should be in the thinlet.jar that I have added the directory to the path, the directory and jarfile name to the System CLASSPATH and it couldn't see it. So finally I tried putting the thinlet.jar in the same directory to no avail. I've searched the web for some time an cannot find anything that specifically speaks to compiling a program that has parent classes in a Jar.
    Any help is definitely appreciated.

    This thinlet class should be in the thinlet.jar that I have added the directory to the path, the directory and jarfile name to the System CLASSPATH and it couldn't see it. So finally I tried putting the thinlet.jar in the same directory to no avail. I've searched the web for some time an cannot find anything that specifically speaks to compiling a program that has parent classes in a Jar.
    Any help is definitely appreciated.You just still haven't provided the jar in the classpath, or you're not using the right class name. Is the class really named thinlet.Thinlet? Or are you thinking "import thinlet.*" means to import all classes in a jar named thinlet.jar? Because the latter is not true. You need to import classes, not jar file names.

  • Drawing from another class

    I have a class Score and in that lcass I have the following method:
      * Draw the score to the applet windows
      * @param g The graphics object
    public void draw(Graphics g, int x, int y)
      calculateScore();
      String stringScore = new Integer(usersScore).toString();
      g.drawString(stringScore, x, y);
    In my Applet class, Driver, I have a global graphics object:
    Graphics gObject;
    I initialize it in the paint method by sayingpublic void paint(Graphics g)
    gObject = g;
    But, inside the Applet when I call the method draw it doesn't work.
    Then I tried
    gObject = getGraphics(0But that didn't work either.
    Is it possible to draw to an applet from another class?
    Thanks.

    I just read one of you other postings on a similiar topic. In that thread everybody is assuming you are using Swing and are giving suggestions based on that assumption.
    In this thread it appears you are using AWT so I gave suggestions based on that assumption.
    It would be nice if you actually asked a clear question and stated what you are doing so people don't waste time guessing what the heck you are trying to do.
    Thats one reason why I always ask for demo code. So we don't waste time guessing.
    If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the code retains its original formatting.

  • Pb deploying applet using sqlj

    Hi,
    I'm trying to deploy an applet I have just created. This applet connects to an Oracle 8.1.7 database using this kind of command:
    Oracle.connect("jdbc:oracle:thin:@ ... );
    Then the applet uses SQLJ class to deal with the datas.
    And after deploying my applet (I have checked all the dependancies to make sure I have everything), when I try to open the html file, I get the following error in the java console:
    java.lang.NoClassDefFoundError: sqlj/runtime/ref/ConnectionContextImpl
         at mypackage5.AppInvest.<init>(AppInvest.java:44)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
         at java.lang.reflect.Constructor.newInstance(Unknown Source)
         at java.lang.Class.newInstance0(Unknown Source)
         at java.lang.Class.newInstance(Unknown Source)
         at sun.applet.AppletPanel.createApplet(Unknown Source)
         at sun.plugin.AppletViewer.createApplet(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Line 44 corresponds to the construction of the sqlj class instanciation.
    I would appreciate any help on this,
    Thanks
    Eric

    OK, you were right ! In fact, I was missing all the jar files in my ARCHIVE tag, but I though that jdevelopper was taking care of all that when deploying the applet. So I don't really see what the advantage of using deploy ...
    However, now, I have another pb. I can launch the applet on my local machine with a www browser. But when trying to connect from other machines, after the loading of jar files, the html page fails on loading my applet itself which is located in mypackage5/AppInvest.class.
    The applet tag is the following:
    <APPLET CODE="mypackage5.AppInvest" ARCHIVE="jdev-rt.jar, runtime12.jar, classes12.jar, nls_charset12.jar" HEIGHT="1000" WIDTH="1000" ALIGN="bottom">This browser does not appear to support Applets.</APPLET>
    I know this is more a html - java pb, but if you have any idea ...
    Thks,
    Eric

  • Using other classes in jsp

    hi all.
    in my jsp i would like to use another class which i created.
    here's what im trying to do:MyUtils.getValue(request.getParameter("id"));i'm getting: MyUtils cannot be resolved
    in MyUtils the method getValue is static.
    where should i put this class in order for my jsp to know it?
    thanks.

    Did you include a page directive with an import for the package? You need something like:
    <%@ page  import="MyUtilsPackage.*" %>The package containing the class should be placed in the WEB-INF\classes directory. For example if the package name is MyUtilsPackage, you'll need a MyUtilsPackage directory under classes and then put the class into the MyUtilsPackage directory.

  • Need to paint objects from one applet into another

    Maybe this question is more at home here; I have an applet test program which uses the timer class to make a car drive across the screen. The test works fine with the rectangle I used, but now I need to use the car created in this class:
       import java.applet.Applet;
       import java.awt.Graphics;
       import java.awt.Graphics2D;
       import java.awt.Rectangle;
       import java.awt.geom.Ellipse2D; 
       import java.awt.geom.Line2D;
       import java.awt.geom.Point2D;
         public class Car extends Applet
              public void paint(Graphics g)
                   Graphics2D g2 =(Graphics2D)g;
                   Rectangle body =new Rectangle(100, 110, 60, 10);
                   Ellipse2D.Double frontTire =new Ellipse2D.Double(110, 120, 10, 10);
                   Ellipse2D.Double rearTire =new Ellipse2D.Double(140, 120, 10, 10);
                   Point2D.Double r1 =new Point2D.Double(110, 110);
                   //the bottom of the front windshield
                   Point2D.Double r2 =new Point2D.Double(120, 100);
                   //the front of the roof
                   Point2D.Double r3 =new Point2D.Double(140, 100);
                   //the rear of the roof
                   Point2D.Double r4 =new Point2D.Double(150, 110);
                   //the bottom of the rear windshield
                   Line2D.Double frontWindshield =new Line2D.Double(r1, r2);
                   Line2D.Double roofTop =new Line2D.Double(r2, r3);
                   Line2D.Double rearWindshield =new Line2D.Double(r3, r4);
                   g2.draw(body);
                   g2.draw(frontTire);
                   g2.draw(rearTire);
                   g2.draw(frontWindshield);
                   g2.draw(roofTop);
                   g2.draw(rearWindshield);
         }The only thing I could think of was making an object of type Car in the test program and then doing something like this:
    Car c =new Car();
    g2.draw(c.paint(g));
    But it says in the test program void type not allowed here. Any tips as to what I'm doing wrong? My guess is that its a problem in the Car class and not the test program, but I didn't think I was supposed to alter Car. (Plus I tried already and couldn't get it to work.)

    what? I don't see what you are trying to do..
    You are trying to make an instance of a class which has no constructor?
    You are trying to move a Panel (an Applet is a subclass of Panel) in another Panel (in Test class?)
    Keep in mind that the Panel automatically has flow layout. In flow layout the components are sized to minimum size, and if the component is another Panel, the minimum size is 0 if there are no components in it.
    Do you need both applets open at once?
    Why not just copy this paint code into your test class?
    Also note that you CAN copy the Graphics from one component onto another, but the Graphics object cannot be null, or you will get a NullPointerException... which is what will happen if you try to copy it in the init() of your test class.
    Why not just make your car a Component (or a Panel even) and give it a constructor? (And make sure to set minimum size to something other than zero?)
    I think you have more than one problem..
    Jen

  • Class not found in applet using 2 jar files

    I have an applet which has been working for years as a stand alone or connecting directly to a derby database on my home server. I have just changed it to connect to MySQL on my ISP server via AJAX and PHP.
    I am now getting a class not found error in my browser, probably because I'm stuffing up the class path.
    The HTML I am using to call the applet is:
    <applet code="AMJApp.class"
    codebase="http://www.interactived.com/JMTalpha"
    archive="AMJ014.jar,plugin.jar"
    width="500"height="500"
    MAYSCRIPT style="border-width:0;"
    name="jsap" id="jsap"></applet>The AMJ014.jar contains the applet and supporting class files.
    The error message is strange to me because it refers to a class I noticed on another web page but which has nothing to do with my applet. Anyway, the message in full is:
    load: class NervousText.class not found.
    java.lang.ClassNotFoundException: NervousText.class
         at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
         at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
         at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Exception: java.lang.ClassNotFoundException: NervousText.class
    java.lang.UnsupportedClassVersionError: AMJApp : Unsupported major.minor version 51.0
         at java.lang.ClassLoader.defineClass1(Native Method)
         at java.lang.ClassLoader.defineClassCond(Unknown Source)
         at java.lang.ClassLoader.defineClass(Unknown Source)
         at java.security.SecureClassLoader.defineClass(Unknown Source)
         at java.net.URLClassLoader.defineClass(Unknown Source)
         at java.net.URLClassLoader.defineClass(Unknown Source)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.defineClassHelper(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.access$100(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader$2.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.plugin2.applet.Plugin2ClassLoader.findClassHelper(Unknown Source)
         at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
         at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
         at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Exception: java.lang.UnsupportedClassVersionError: AMJApp : Unsupported major.minor version 51.0

    Thanks again.
    The page code is:
    <html>
    <head>
      <title>Applet to JavaScript to PHP</title>
    </head>
    <body>
    <script type="text/javascript">
    function updateWebPage(myArg)
    document.getElementById("txt1").innerHTML=myArg;
    if (myArg=="")
      document.getElementById("cbxItem").innerHTML="";
      return;
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
    else
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    xmlhttp.onreadystatechange=function()
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        document.getElementById("cbxItem").innerHTML=xmlhttp.responseText;
    xmlhttp.open("GET","putitem.php?id="+myArg,true);
    xmlhttp.send();
    </script>
    <form>
    <table border=1 align='center' cellpadding=0 cellspacing=0 >
    <tr><td style='text-align:center; background-color:#C0C0C0'>Compiled Java Applet</td></tr>
    <tr><td><applet code="AMJApp.class" codebase="http://www.interactived.com/JMTalpha" archive="AMJ014.jar" width="500"height="500" MAYSCRIPT style="border-width:0;" name="jsap" id="jsap"></applet> </td></tr>
    <tr><td style='text-align:center; background-color:#C0C0C0'>HTML Textbox filled by JavaScript</td></tr>
    <tr><td><textarea style='width:500px; height:50px' name='txt1' id='txt1'>Query goes here</textarea></td></tr>
    <tr><td style='text-align:center; background-color:#C0C0C0'>HTML diagnostic messages rendered by PHP script</td></tr>
    <tr><td><div id="cbxItem">PHP info will populate this space</div></td></tr>
    </table>
    </form>
    </body>
    </html>The URL of the problem page is:
    http://www.interactived.com/JMTalpha/AMJTest.htm
    The code in the page is based on the following test page, which works:
    http://www.interactived.com/test5Applet.htm
    And the Applet, before I made any changes can be seen at this address:
    http://www.interactived.com/jartest0906.htm
    Thanks again for you interest.
    Edited by: 886473 on 21-Sep-2011 00:47

  • Using a class that has a main from another class

    Can I call a class that has a main from another classes public methods?

    Yes, you can, although strictly speaking you won't be calling that classes "main" method, you will simply be calling and initializing the class through it's constructor, the "main" method will be ignored. If you have code inside your main method that you want executed as well consider moving it inside your constructor and simply using the "main" method as an application initializer:
    public static void main( String args[] ) {
    new MyClass();
    This way you can use your class as an application or call it from another class and not have any duplicate code inside your "main" method and constructor. You can also take this further and have it call the applet initialization so that you can launch it any way you like, I suspect this is a bit beyond what you were asking.
    Does this solve your problem?

  • Using a variable from another class

    hello friends, I have a class with the follow variable: dbcolTempMax, and the value of this variable I need in another class, how can do to use the value of the variable...thanks

    Both people above described the solution, but from the question I take it you are somewhat new to programming. Let me give you a code example which may help.
         public class ClassWithVariable {
              private int dbcolTempMax;
              public int getDbcolTempMax() {
                   return dbcolTempMax;
         public class SomeOtherClass {
              ClassWithVariable cwv = new ClassWithVariable();
              cwv.getDbcolTempMax(); // This gets the value of the variable
         }Now if the variable is static, you can provide a static "accessor" method to ge the variable. This will save you the trouble of constructing an object of the class.
    Cheers,
    Cypher

  • Use a counter from one class to another class of the same project

    Hello!
    In my class Book I have a variable, which is in fact a counter, counts the number of books. I need to use this same variable in another class Library, and I want to know if this is possible by any means!
    Thank You very much for Your support!

    Read this carefully.
    Regards,

  • Problem when used InetAddress class in Applet

    Hi all.
    I'DongPG from Vietnam.
    I have a question'How to get IP that different from IP default "127.0.0.1" address'.
    I've built an applet where i used InetAddress class to get browser'IP follow:
    InetAddress localIP = InetAddress.getLocalHost();
    String strIP=localIP.getHostAddress();
    I used JBuilder to build applet. It's gotten IP right. Ex:strIP='192.168.100.1'
    But when i used browser link to my Applet in WebServer, it only return strIP='127.0.0.1'
    Thank a lot!

    Wrong forum and cross posted as well.

  • How to update and use the values of variables of another class

    I can we update or use the values of the variables of another class. For example, if we have class A
    public class A //(situated in package view)
    public s0,s1;
    public void runFunction()
    ...some coding and proceedings
    s0="Hi";s1"Hello";
    ......some coding
    RequestDispatcher dispatcher = request.getRequestDispatcher("/MainUser.jsp?alert=F");
    dispatcher.forward(request, response);
    ARunner.jsp
    <jsp:useBean id="a" class="view.A" scope="session"/>
    <%
    a.runFunction();
    %>
    MainUser.jsp
    <jsp:useBean id="a" class="view.A" scope="session"/>
    <%
    System.out.println("S0:"+a.s0+" S1:"+a.s1); //should print S0:Hi S1:Hello, but printing S0:null S1:null
    %>
    A.class has some procedures and String variables which can be updated and later can be used in JSP pages. The project starts with ARunner.jsp which uses the A.class and updates the values of string variables s0 and s1of A to hi and hello respectively.And then redirects the page to MainUser.jsp.
    Now what I want is ,when I call those string variables(s0 & s1 of A.class) in any another jsp likeMainUser.jsp it should give me the value of hi and hello respectively not null as it is giving right now. Could you refine the coding for this one?

    public class A //(situated in package view)
    public String s0,s1;
    public void runFunction()
    ...some coding and proceedings
    s0="Hi";s1"Hello";
    ......some coding
    RequestDispatcher dispatcher = request.getRequestDispatcher("/MainUser.jsp");
    dispatcher.forward(request, response);
    ARunner.jsp
    <jsp:useBean id="a" class="view.A" scope="session"/>
    <%
    a.runFunction();
    %>
    MainUser.jsp
    <jsp:useBean id="a" class="view.A" scope="session"/>
    <%
    System.out.println("S0:"+a.s0+" S1:"+a.s1); //should print S0:Hi S1:Hello, but printing S0:null S1:null
    %>
    giving code again to remove the typing errors. Please guide.

Maybe you are looking for

  • Inconsistency BSEG, BSIS, BSAS

    Hi, likeable consultants! In transactions reports: FBL3N and FS10N I have differents accounts balances display. analyzing BSEG Table, I have 15 line itens, and BSIS and BSAS have 18 line itens. I request a solution to adjust these 3 line itens to bal

  • Open Hub, Delta Transformation

    Hi All, Thanks in advance for your help.  I am extracting data from a DSO to a flat file using an Open hub and a delta DTP.  The problem I have is that if there is no delta (i.e. zero new/changed records) since the last time the open hub ran, my file

  • Not able to connect to express AND computer

    Running newest everything (itunes and express firmware). I have the express hooked up to speakers in another room. Both my PC and my Mac are connected to a linksys wrt54g (although even when i use the ibook's wireless connection to connect the same t

  • Invoke Runbook Activity doesn't finish

    Hello, I have a Problem with the Invoke Runbook Activity, if I just test the Child Runbook manually it works fine but if I want to start it via the Parent Runbook it gets stucks and never finishes. Parten Runbook: Child Runbook: The Child Runbook is

  • 2 S750's with say 12 sats.

    Possible to get both subs working correctly? and 2 sats. pretty much 2 sats per channel besides front left and right. Ive got s750 at the moment, 2 per side channel, works fine, but, i know its not exactly awesome because of power output or what ever