How to pass a populated Java bean to a jsp

Hi,
I'm new to J2EE world. I want to know how should I pass a populated Java Bean (not EJB) to a JSP without displaying that JSP in the next step. I would be much grateful to anyone who gives a solution to my problem.
Thanks in advance
With best regards
Sampath

> I'm new to J2EE world. I want to know how should I
pass a populated Java Bean (not EJB) to a JSP without
displaying that JSP in the next step.
Urk?
A JSP is meant to be displayed. If there's business logic in that JSP, get it out of there. Process the bean as needed on the server side and send the flow on to some view that actually should be displayed.
~

Similar Messages

  • How can i  apply this  java program for  a jsp page?

    import java.io.*;
    import java.util.*;
    public class FileProcessing
      //create a vector container  for the input variables
         Vector variables = new Vector();
      //create a vector container for the constants
         Vector constants = new Vector();
      /*create a string expression container for the equation
         as read from the file */
         String expression = " ";
      //create double result container for the final result
         double result = 0;
         public boolean processFile(String filename,String delim)
          //index for values vector
              int num_values = 0;
          //index for constants vector
              int num_constants = 0;
          //current line being read from the external file.
              String curline = " ";
          //start reading from the external file
              try
                   FileReader fr = new FileReader(filename);
                   BufferedReader br = new BufferedReader(fr);
                   while(true)
                        curline = br.readLine();
                        if(curline == null)
                             break;
                    //determine the type of current interaction
                        boolean variable = curline.startsWith("input");
                        boolean constant = curline.startsWith("constant");
                        boolean equation = curline.startsWith("equation");
                        boolean output = curline.startsWith("result");
                   //on input variables
                        if(variable)
                          StringTokenizer st = new StringTokenizer(curline,delim);
                          int num = st.countTokens();
                          int count=0;
                          while(st.hasMoreTokens())
                               String temp = st.nextToken();
                               if(count==1)
                                    byte b[]= new byte[100];
                                    System.out.println(temp);
                                    System.in.read(b);
                                    String inputval = (new String(b)).trim();
                                    variables.add(num_values,inputval);
                                    num_values++;
                               count++;
                        // on constant values
                        if(constant)
                             StringTokenizer st = new StringTokenizer(curline,delim);
                             int num = st.countTokens();
                             int count = 0;
                             while(st.hasMoreTokens())
                                  String temp = st.nextToken();
                                  if(count==1)
                                       byte b[]= new byte[100];
                                       System.out.println(temp);
                                       System.in.read(b);
                                       String cons = (new String(b)).trim();
                                       constants.add(num_constants,cons);
                                       num_constants++;
                                  count++;
                        // on equation
                        if(equation)
                             StringTokenizer st = new StringTokenizer(curline,delim);
                             int num = st.countTokens();
                             int count = 0;
                             while(st.hasMoreTokens())
                                  String temp = st.nextToken();
                                  if(count==2)
                                       this.expression = temp;
                                  count++;
              // now we are ready to evaluate the expression
                       if(output)
                          org.nfunk.jep.JEP  myparser= new org.nfunk.jep.JEP();
                          myparser.setAllowAssignment(true);
                          for(int i=1;i<variables.size()+1;i++)
                             String name = "arg"+Integer.toString(i);
                             myparser.addVariable(name,new Double(variables.get(i-1)
                                                .toString()).doubleValue());
                          for(int i=1;i<constants.size()+1;i++)
                               String name = "arg" +Integer.
                                         toString(i+variables.size());
                               myparser.addConstant(name,new Double(constants.get(i-1).toString()));
                   //output is obtained as follows
                          myparser.parseExpression(expression);
                          result = myparser.getValue();
                          System.out.println("Assay value: "+result);
              catch(Exception e)
                   System.out.println(e.toString());
              return true;
         public static void main(String[] args)
              FileProcessing fp = new FileProcessing();
              fp.processFile("input.eqn",":");
    }//my text file name is: "input.eqn" (given below)
    input:Enter Value1:arg1
    input:Enter Value2:arg2
    input:Enter Value3:arg3
    constant:arg4
    constant:arg5
    Equation:arg1+arg2+arg3
    result:

    how can i apply this java program for a jsp pagewhy do you want to do this ?
    Your program reads from a file on the disk and formats based on a patterm.
    Jsp is not intended for such stuff.
    ram.

  • How to include PJC and Java Beans in forms

    I have tried a lot to include java codes in my forms ..So I decide to start with ProgressBarPJC(cause it is tested and provided with demo) but I could not set implementation class of java bean object to
    oracle.forms.demos.ProgressBarPJC it does not accept it but it accept ProgressBar instead of ProgressBarPJC. I don't know why? I have made changes in Forms90_builder_classpath to access f90all.jar and progressbar.jar. I have Progressbar.class and progressbarpjc.classs both but i don't know how to set implementation class to ProgressBarPJC.
    don't you think there is lots of configuration and path setting to use any JPC or Jar in forms? I am totally confused with this integration.
    Please solve this matter
    Thanking you,
    Neeraj

    and even more information samples and step by step instructions are on the Java spotligh on the Forms Upgrade Center : http://otn.oracle.com/formsupgrade

  • Need some help how to generate xml from java bean.

    Hi,
    Can some one help me how to generate the xml format output from a java bean.
    The bean contains around 15 to 20 attribute values.
    Thanks in Advance.
    sarayu

    You can use XMLEncoder with custom persistence delegates if needed:
    http://java.sun.com/products/jfc/tsc/articles/persistence4/

  • How to deploy the wrapped Java Bean on PowerBuilder

    Using the JavaBeans Bridge for ActiveX Packager, I could generate the .tbl and .reg files for my Java Bean. Since I am a 100% Java guy and don't have much knowledge of PowerBuilder, I don't know how to deploy this on PB. When I try to register an OLE, PB looks for the files with an extension .ocx but not .tbl. Please let me know how I can see my wrapped up Java Bean on PowerBuilder or on VB.
    Thanks a lot in advance.

    I found it, I have to update the system registry with the .reg file and then the java bean automatically gets listed in the controls list in PB.

  • Challenge: How to create an BMP Java Bean from a DBF Database??

    Hello guys....
    This is my challenge and looking for some aim:
    I was asked to create an application that must read from an existing DBF Database of products (That is already used by an administrative system) an build a Price List in Real Time. The program must be accesible through Intranet using a web browser.
    The Appplication Client must be a faster GUI (Applet or App) that do not cause interference in the normal functions of the Administrative System that owns the DBF Database, but must propagate any change maded to the database in real time.
    I was thinking to use BMP Entity Beans for manage the DBF Tables and Utility Beans to avoid constan access to the tables (As in Duke�s Bank Tutorial) but i do not know how to create a BMP Entity Bean without a Database that do not have an JDBC Driver ?????????
    i was able to gain access to DBF TAbles using an small library called TinySQl but i get lost in this point....
    any suggestions/comments about following matters will be apreciate:
    1.- Application Performance Tips
    2.- A better JDBC Driver for DBF Databases
    3.- Application�s Security
    4.- User Management
    5.- Any comments in general !!!!!!!!!!
    Initially 15 Duke�s Dollar will be offered to the best anwser, but i considering to offer 5 duke�s dollar to the best second anwser that can be earned through another post i will create later!!!!!!!!!11
    Regards.................

    Hello guys....
    This is my challenge and looking for some aim:
    I was asked to create an application that must read
    from an existing DBF Database of products (That is
    already used by an administrative system) an build a
    Price List in Real Time. The program must be
    accesible through Intranet using a web browser.
    The Appplication Client must be a faster GUI (Applet
    or App) that do not cause interference in the normal
    functions of the Administrative System that owns the
    DBF Database, but must propagate any change maded to
    the database in real time.
    I was thinking to use BMP Entity Beans for manage the
    DBF Tables and Utility Beans to avoid constan access
    to the tables (As in Duke�s Bank Tutorial) but i do
    not know how to create a BMP Entity Bean without a
    Database that do not have an JDBC Driver ?????????
    i was able to gain access to DBF TAbles using an
    small library called TinySQl but i get lost in this
    point....
    any suggestions/comments about following matters will
    be apreciate:
    1.- Application Performance Tips
    2.- A better JDBC Driver for DBF Databases
    3.- Application�s Security
    4.- User Management
    5.- Any comments in general !!!!!!!!!!
    Initially 15 Duke�s Dollar will be offered to the
    best anwser, but i considering to offer 5 duke�s
    dollar to the best second anwser that can be earned
    through another post i will create later!!!!!!!!!11
    Regards.................
    PLEASE DO NOT POST REPLIES IN THIS THREAD, USE THE UPPER THREAD THAT HAVE 10 DUKE�S DOLLARS ASSIGNED.
    SORRY

  • How to embed excel in java bean area on oracle forms 9i?

    Hi,
    I am trying to embed excel in oracle forms 9i using java bean. I want to open excel sheet in the bean area not as seprate application. Means i donot want to excel running separately from forms on the machine.
    If any body knows the solution please reply.
    Best regrads,
    Shiraz

    Hi
    Is it possible to create a java bean, with a click event which populates data from database table to an excel sheet.
    The data(can be obtained in a string format with delimiters, but can anyone help me in exporting this into an excel sheet). and also to provide user to take prints of the data in the excel sheet.
    If Print of the JTable could be done(by settin printable as this), but this involves unwanted buttons to be printed, and entire table is not available in the spread sheet format.
    Thanks in Advance
    Deepa

  • How to pass variable from Java to ABAP in BSPs

    Hello experts,
    taking into account the two environments (browser and server) I need to pass information from Java to ABAP.
    After seen this link: Re: View Refresh
    I have tried the next:
    HTMLB:  <input type="hidden" name="myFlag" value="">
    ABAP:   DATA: lv_height TYPE STRING.
    JAVA:   var intXo = readCookie("XEix");
    JAVA:   if ( intXo == 900 )                
    JAVA:   else if (intXo == 725 )            
    ABAP:   lv_height = request->get_form_field( 'myFlag' ).
    ABAP:   IF lv_height EQ 'X'.
    ABAP:     TRAYTAREAS_P = 'TRUE'.
    ABAP:   ELSE.
    ABAP:     TRAYTAREAS_P = 'FALSE'.
    ABAP:   ENDIF. 
    "document.all.myFlag.value" gets the correct value according the condition, but the ABAP code does not recover this value (lv_height is always initial).
    Can you help me with that? I'm not able to see where is the mistake...
    Exist any alternative way to recover in ABAP an JavaScrip value?
    thanks in advance.
    Arnau
    Message was edited by:
            Arnau Mustieles

    Hi Raja
    I think you are appointing to this posted solution:
    HTMLB: <input type="hidden" name="myFlag" value="">
    ABAP: DATA: lv_height TYPE STRING.
    JAVA: var intXo = readCookie("XEix");
    JAVA: if ( intXo == 900 )
    JAVA: else if (intXo == 725 )
    ABAP: lv_height = request->get_form_field( 'myFlag' ).
    ABAP: IF lv_height EQ 'X'.
    ABAP: TRAYTAREAS_P = 'TRUE'.
    ABAP: ELSE.
    ABAP: TRAYTAREAS_P = 'FALSE'.
    ABAP: ENDIF.
    but it doesn't work. Can you detect if there is any evident error there or the process is right?

  • How to make countdowntimer in java bean to use in jsp form

    i make an aplication in jsp with XHTML MP format..i have problem to maka a countdowntimer in java bean to use in the jsp form.could anyone help me with this problem

    Use JHelp, downloadable from Sun. This is a quit big package, you have to read a lot before applying.
    http://java.sun.com/products/jfc/tsc/articles/javahelp/index.html
    enjoy
    sergio

  • How to pass a command line argument to a jsp file...

    Hi guys,
    I'm writing a jsp file in which I have some java codes. I want to pass some command line arguments to that jsp file. In other words, I have some files located somewhere on my C drive and I want to pass the path to these files to my jsp file. How can it be done? I have never done before.
    Any suggestion will be very hepful...
    Thanks....

    I dont know if I truly understand your problem...
    For instance, when you place the url of your jsp you can add, at the end some parameters. For example:
    http://myserver/myapp/myjsp.jsp?MyParameter=C:\Temp\JavaTutorial.html
    In your JSP, you can place this code on a scriplet to get the value:
    String path = request.getParameter("MyParameter");
    Hope it helps.

  • Calling a java bean in a jsp file

    hi all
    i am working on a jsp project. my tomcat is installed on one machine and my java Bean on another. how do i call the javabean on my machine from the jsp file on tomcat. i'm using packages.
    eg:
    in the jsp file in tomcat, i'm using
    <jsp:useBean id="student" scope="request" class="lab3.Student"/>
    i get class not found error.
    my main path for this Student Bean is say c://myLab/lab3 which has a lab3 folder with class files.
    Thanks

    eg:
    in the jsp file in tomcat, i'm using
    <jsp:useBean id="student" scope="request"
    class="lab3.Student"/>
    If you have a Context defined for c://mylab
    then below that directory you should have a WEB-INF directory and then a classes directory and then within that your package structure...
    so if the package is lab3 yo should have your Student class in:
    c://mylab/WEB_INF/classes/lab3/Student.class
    (asuming you have set up a Context that points at c://mylab...and your jsp file is there...)

  • How To pass the value within the page using jsp?

    How to passing the textbox value within the jsp page without using javascript or reload the page.
    I have a scenario like this:
    I have a textbox named as "accno" which allow user to key in the accno. After key in the accno, this accno value will used to do a query from database using jstl.
    here is part of my code
    <input name="accno" type="text" onChange="checkLC()"/>
    <sql:query var="results" dataSource="${db}">
    select accno,name from account where accno = '<%=value get from accno textbox%>'          
    </sql:query>
    <c:out value="${result.rows[0].name}"/>
    note that onChange() is the javascript when user key in accno then automatically go to check database then only show out the name. So how can i get the '<%=value get from accno textbox%>' from accno textbox.

    How to passing the textbox value within the jsp page
    without using javascript or reload the page.No, jsp executes on the remoter server, the text box is on a client machine, you need to send information to the server over the network, http does this with a request, which will reload the page.....................

  • Cannot compile java beans in my jsp page

    Hi all
    I have created jsp pages which contains java beans. Now its working fine on my machine(XP OS) but when i put it on windows 2000 server it gives the following error:
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: -1 in the jsp file: null
    Generated servlet error:
    [javac] Since fork is true, ignoring compiler setting.
    [javac] Compiling 1 source file
    [javac] Since fork is true, ignoring compiler setting.
         at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:130)
         at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:293)
         at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:353)
         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:370)
         at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:473)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:190)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
         at java.lang.Thread.run(Unknown Source)
    please help

    Ok, jsp pages to not contain java beans, java beans are separate classes which you access from a jsp.
    Is this what you have done, i.e. created classes under classes/yourPackage ?
    If so, you do not need to recompile the class when you move it, you can move the pre-compiled class file.
    In terms of your error, I have no idea, but it looks interesting!!
    The most likely cause is a difference in the JDK versions you are running on the different machines. If the JDK on windows 2000 is older, you may need to upgrade it.

  • How to pass servlet parameter using encodeURL function in JSP page

    Hi!!!
    I have a very urgently problem.
    in my JSP I have this:
    <IMG border="0" src='<%=response.encodeURL("/MyImageServlet")%>'>
    In this way, my servlet works fine (and I have in my page my blob-image).
    But I have to pass to my servlet a list of dynamic parameter. I have tried all the possibilities like:
    <IMG border="0" src='<%= (response.encodeURL("/MyImageServlet") + "?Param_name=" + sessionBean.getParamValue() + "&anotherParam" + sessionBean.getAnotherParamValue())%>'
    but nothing....
    In my servlet I use the init function to retrieve the initial parameters(defined in my web.xml file) in this way:
    public void init(ServletConfig config) throws ServletException
    super.init(config);
    myParam = getInitParameter( "name_of_param");
    but I retrieve only the default value (-1).
    How to pass to my servlet the parameters? Please help me!
    Excuse me for my english,
    thank you for your help!

    Hi!
    Thanks for your reply!
    I have tried this solution but it doesn't work!
    When I do getInitParameter in the init function, the servlet take the default values...
    Maybe I have wrote something wrong?
    Excuse me for my english,
    Thanks

  • Java Bean Error in JSP: Cannot Resolve Symbol FirstBean

    I have created a java bean with following package statement
    package mybeans;
    and my bean name is
    FirstBean
    it compile secessfully and now my directory structure is following
    WebAppRootDir \ WEB-INF \ classes \ mybeans \ FirstBean.class
    I am using Tomcat 4.1 and in JSP i am declaring the bean with following line
    <jsp:useBean id="b" class="mybeans.FirstBean" />
    and tomcat 4.1 is failed to find this bean and giving me following error
    cannot resolve symbol
    symbol  : class StudentBean 
    location: package mybeans
    mybeans.FirstBean b = null;
    all my class and directory structure is ok i am puzzle why this error is coming, plz help me quickly i need solution quickly ...

    Error is for StudentBean, not for FirstBean. So check for it.

Maybe you are looking for