Using javabean problem

Hi all,
I need to call function in java program in jsp , i use it as javabean but i found one function does not work, I think it may be because that functions related to the other class, though i have put them inside the right folder. what i would like to know is can the function be called in jsp using javabean if the function involve other class? thanks!!

Hi You can call that function using
<jsp:useBean id="beanInstanceName" class="package.class"/>
<jsp:setProperty name="beanInstanceName" property="*"/> // for setting the all attribute os the javabean class.
for gettiing the function of getting the value of attribute.
<jsp:getProperty name="beanInstanceName" property="propertyName"/>
or
call with the
<jsp:useBean id="beanInstanceName" class="package.class"/>
<%=beanInstanceName.getMthodName%> within ur Jsp.
Try this.
Thanks
Vivek

Similar Messages

  • Jsp and JavaBean problem

    Hi All,
    I need UR help
    Problem:
    I have a javaBean and a jsp page say test.class and test.jsp respectively.
    Now the problem is when i run my jsp in web browser with path
    http://localhost:8080/mypackage/test.jsp and use test.class in it. It give me an error Class test.class Not Found but when i give the path http://localhost:8080/examples/jsp/parentpackage/mypackage/test.jsp
    it works fine.
    I am using Tomcat 3.2 and i have already made changes in server.xml for my jsp files thats why i can run my programs with the earlier path but dont know why its giving the error when i use javabean,
    Also i have put my javabean class in---parentpackage/mypackage/test.class
    Thanks
    Amit

    hi there,
    Thanks for you time, here i have placed the source for jsp and javabean
    Please excuse me if you find the code unproper
    Code for JSP:
    <%
    response.setHeader("Pragma","No-cache");
    response.setDateHeader("Expires",0);
    response.setHeader("Cache-control","No-cache");
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Internal Clarification-Agent View</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body background="images/c.jpg" bgproperties="fixed">
    <%@ page language="java" import="java.sql.*" %>
    <%@ page import="javax.servlet.*" %>
    <%@ page import="java.io.*" %>
    <%@ page import="java.util.*" session="true"%>
    <%@ page import="java.util.Date" %>
    <%@ page import="java.sql.Timestamp" %>
    <%@ page import="java.text.*" %>
    <%@ page import="java.lang.*" %>
    <%@ page import="javax.servlet.http.*"%>
    <jsp:useBean id="navi" class="arvato.interclarification.rqchunk" scope="session" />
    <%
    try{
    Connection con = null;
    PreparedStatement ps = null;
    PreparedStatement ps1 = null;
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection("jdbc:odbc:interdsn","","");
    String qrno = request.getParameter("qrno");
    String rdb = request.getParameter("rb");
    String key = request.getParameter("key");
    String cname = request.getParameter("cname");
    //out.print(key);
    //if(st.equals("All")){
    String sql="";
    if(rdb!=null){
    if(rdb.equals("1")){
    if(qrno==null||qrno.equals("")){
    sql = "SELECT * FROM crequired ORDER BY adate DESC";
    else if(qrno!=null){
    sql = "SELECT * FROM crequired WHERE queryno LIKE '"+qrno+"%'";
    }else if(rdb.equals("2")){
    if(key==null||key.equals("")){
    sql = "SELECT * FROM crequired ORDER BY adate DESC";
    else if(key!=null){
    sql = "SELECT * FROM crequired WHERE clarification LIKE '"+key+"%'";
    else if(rdb.equals("3")){
    if(cname==null||cname.equals("")){
    sql = "SELECT * FROM crequired ORDER BY adate DESC";
    else if(cname!=null){
    sql = "SELECT * FROM crequired WHERE fname LIKE '"+cname+"%'";
    if(rdb==null)
    sql = "SELECT * FROM crequired ORDER BY adate DESC";
    ps = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
    //ps.setString(1,space);
    /*}else{
    sql = "SELECT * FROM crequired WHERE status=? AND space=?";
    ps = con.prepareStatement(sql);
    ps.setString(1,st);
    ps.setString(2,space);
    ResultSet rs = ps.executeQuery();
    %>
    <table width="100%" border="0" cellspacing="0">
    <tr>
    <td width="50%"><strong><img src="images/microsoftlogo1.jpg" width="288" height="94"></strong></td>
    <td width="50%"><div align="right"><strong><img src="images/logo2.jpg" width="177" height="77"></strong></div></td>
    </tr>
    </table><br>
    <hr noshade color="#000000">
    <div align="center"><font color="#990000" size="4" face="Verdana, Arial, Helvetica, sans-serif"><strong>CSR
    VIEW</strong></font>
    </div>
    <form name="form" method="post" action="agentview1.jsp">
    <table width="59%" border="1" align="center" cellpadding="2" cellspacing="0">
    <tr>
    <td width="49%"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>
    <input name="rb" type="radio" value="1" <%if(rdb!=null){if(rdb.equals("1")){out.print("checked");}}%>>
    <font size="1">SEARCH BY QUERY NUMBER:</font></strong></font></td>
    <td width="51%"><input name="qrno" type="text" id="qrno"></td>
    </tr>
    <tr>
    <td><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    <input type="radio" name="rb" value="2" <%if(rdb!=null){if(rdb.equals("2")){out.print("checked");}}%>>
    <font size="1"> SEARCH BY KEY WORD:</font></font></strong></td>
    <td><input name="key" type="text" id="key"></td>
    </tr>
    <tr>
    <td><input type="radio" name="rb" value="3" <%if(rdb!=null){if(rdb.equals("3")){out.print("checked");}}%>>
    <strong><font size="1" face="Verdana, Arial, Helvetica, sans-serif">SEARCH
    BY CSR NAME:</font></strong></td>
    <td><input name="cname" type="text" id="cname"></td>
    </tr>
    <tr>
    <td colspan="2"><div align="center">
    <input type="submit" name="Submit" value="Submit">
    </div></td>
    </tr>
    </table>
    </form><br>
    Back
    <%
    navi.setchunk(10);
    navi.setRS(rs);
    String v="";
    String vv=request.getParameter("off");
    if(vv==null){v="1";}
    else{
    v=vv;
    int i=Integer.parseInt(v);
    navi.setcursor(i);
    ResultSet rs2=navi.getRS();
    int h1=1;
    if(request.getParameter("off")!=null) h1=Integer.parseInt(request.getParameter("off"));
    int h2= navi.getchunk();
    int h3= navi.getcount();
    int offset=(h3-h1)<h2?h3:(h1+h2-1);
    %>
    <table width=100%><tr><td width=33%> </td><td align=center width=34%><font face="verdana, arial" size=2 color=#000000>Displaying <%=h1%> to <%=offset%> of <font size=4><%=h3 %></font></font></td><td width=33%> </td></tr></table>
    <%
    int c1=navi.getcount(),c2=navi.getchunk();
    int c3=navi.getcursor();
    int c4=c3+c2;
    int c5=c3-c2;
    %>
    <table width=100% ><tr><td align=left width=100% >
    <%
    if(c3>c2 && c3<=c1){
    out.print("<a href=\"agentview1.jsp?n=y&off="+c5+"\">Previous</a>");
    %></td><td align=right width=100%>
    <%
    if(c1>c2 && (c1-c3)>=c2){
    out.print("<a href=\"agentview1.jsp?n=y&off="+c4+"\">Next</a>");}
    %>
    </td></tr></table>
    <table width="1359" border="0" cellspacing="1">
    <tr bgcolor="#3C6C84">
    <th width="2%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">S.No.</font></th>
         <th width="5%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Query No</font></th>
    <th width="5%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Clarification
    Posting Date & Time</font></th>
         <th width="3%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Posted
    By</font></th>
    <th width="6%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Received
    By</font></th>     
    <th width="3%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Sub
    Process </font></th>
         <th width="4%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Region</font></th>
    <th width="5%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Status</font></th>     
    <th width="15%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Clarification
    Required OnQuery </font></th>
    <th width="18%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Solution</font></th>
    <th width="8%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Date
    & Time Visited On</font></th>
    <th width="7%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Date
    & Time Closed On</font></th>
    <th width="5%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Remarks</font></th>
    </tr>
    <%
    int m = 0;
    for(int l=0;l<c2 && i<=c1;l++,i++){
    //while(rs.next()){
    m = m+1;
    String queryno = rs.getString("queryno");
    //out.print(queryno);
    %>
    <tr>
    <td bgcolor="#FFFFCC"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><%=m%></b></font></td>
         <td width="5%" bgcolor="#FFE4CA"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><%=queryno%></b></font></td>
    <td bgcolor="#FFFFCC"><font face="Verdana, Arial, Helvetica, sans-serif" size="1">
    <%Date d1 = rs.getDate("adate");
         String dd1="";
         SimpleDateFormat sddf = new SimpleDateFormat("MM/dd/yyyy");
         dd1 = sddf.format(d1);
         Date t1 = rs.getTime("atime");
         String tt1="";
         SimpleDateFormat stdf = new SimpleDateFormat("HH:mm");
         tt1 = stdf.format(t1);
         String ttm = dd1+" "+tt1;
         out.print(ttm);     
         %></font>
    </td>
         <td bgcolor="#FFE4CA"><font face="Verdana, Arial, Helvetica, sans-serif" size="1">
    <b><%String fnm = rs.getString("fname");
    String lnm = rs.getString("lname");
    String nm = fnm+" "+lnm;
    out.print(nm);
    %></b></font></td>
    <td width="6%" bgcolor="#FFFFCC"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><%
         String tnm = rs.getString("tname");
         if(tnm.equals("null")||tnm.equals("-")){}else{out.print(tnm);}
         %></font></td>
         <td bgcolor="#FFE4CA"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><%=rs.getString("space")%></b></font></td>
         <td bgcolor="#FFFFCC"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><%String rg = rs.getString("region");
         if(rg==null||rg.equals("null")){}else{out.print(rg);}%></b></font></td>
         <%String status = rs.getString("status");
         if(status.equalsIgnoreCase("New")){%><td bgcolor="#FF0000"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#FFFFFF"><b><%=status%></b></font></td>
         <%}else if(status.equalsIgnoreCase("Open")||status.equalsIgnoreCase("Awaiting MS Reply")){%><td bgcolor="#FFCC33"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#FFFFFF"><b><%=status%></b></font></td><%}else{%><td bgcolor="#00CC00"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#FFFFFF"><b><%=status%></b></font></td><%}%>
    <td bgcolor="#FFE4CA"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#0000CC"><%=rs.getString("clarification")%></font></td>
         <%
    //String queryno = rs.getString("queryno");
    String qry1 = "select * from csolution where queryno=?";
    ps1 = con.prepareStatement(qry1);
    ps1.setString(1,queryno);
    ResultSet rs1 = ps1.executeQuery();
    while(rs1.next()){%>
    <td bgcolor="#FFFFCC"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><%=rs1.getString("solution")%></font></td>
         <td bgcolor="#FFE4CA"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><%
         Date dp = rs1.getDate("dateofopen");
         String dp1="";
         SimpleDateFormat spdf = new SimpleDateFormat("MM/dd/yyyy");
         dp1 = spdf.format(dp);
         Date tp = rs1.getTime("timeofopen");
         String tp1="";
         SimpleDateFormat stpf = new SimpleDateFormat("HH:mm");
         tp1 = stpf.format(tp);
         String tpm = dp1+" "+tp1;
         out.print(tpm);
         %></font>
    </td>
         <td width="5%" bgcolor="#FFFFCC"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><%
         Date dc = rs1.getDate("dateofclose");
         String dc1="";
         SimpleDateFormat scdf = new SimpleDateFormat("MM/dd/yyyy");
         dc1 = scdf.format(dc);
         Date tc = rs1.getTime("timeofclose");
         String tc1="";
         SimpleDateFormat stcf = new SimpleDateFormat("HH:mm");
         tc1 = stcf.format(tc);
         String tcm = dc1+" "+tc1;
         out.print(tcm);
         %></font>
    </td>
         <td width="16%" bgcolor="#FFE4CA"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><%String remarks = rs1.getString("remarks");
         if(remarks==null){}else{out.print(remarks);}
         %></font></td>
    <%}navi.setcursor();
    }con.close();}catch(Exception e){out.print(e);}%>
    </tr>
    </table><br>
    <font size="2" face="Verdana, Arial, Helvetica, sans-serif">Back to
    Main Menu</font>
    </body>
    </html>
    Code for javaBean:
    package arvato.interclarification;
    import javax.servlet.http.*;
    import java.sql.*;
    public class rqchunk
              ResultSet rs=null;
              int chunk=5;
              int count=0;
              int cursor=1;
              public rqchunk(){}
              public void setRS(ResultSet rset) throws SQLException
                   rs = rset;
                   int cnt=0;
                   while(rs.next())
                        cnt++;
                   rs.absolute(1);
                   count=cnt;
              public void setcursor()throws SQLException
                   cursor++;
                   rs.absolute(cursor);
              public void setcursor(int i)throws SQLException
                   cursor=i;
                   rs.absolute(cursor);
              public int getcursor()
                   return cursor;
              public int getchunk()
                   return chunk;
              public void setchunk(int i)
                   chunk=i;
              public void setcount(int j)
                   count=j;
              public int getcount()
                   return count;
              public ResultSet getRS()
                   return rs;
              public void clearRS()
                   cursor=0;
                   rs=null;
    Please excuse me if my codes are not understandable enough
    Thanks
    Amit

  • How to use javabean

    can anyone can have a easy understand explain for how to use javabean?
    for example, if i am going to have a bean named "Dog", which will can speak "blah blah blah". what is the procedure to get it work?
    thanks

    Hi.
    I'm not quite sure what you're asking, but I'll give it a shot at a simple explanation. Let's say you create a Dog bean. A Bean is really just a Class that follows some general rules and naming conventions to make interpreting of the exported interface easier.
    The Java Beans specification says that the Dog bean should be serializable - That is, you can modify the values in the fields of Dog (i.e., you could change it's breed, or it's name, or it's owner, or what ever other fields you have), and write it out to a file, and load it back at a later time, and these fields would still have memory of the changes you made earlier. This is called persistance.
    Further to this, a bean declares properties as fields xxx that have matching methods getXxx and setXxx. Let's say you wish to have several dogs, one that speaks "arf", one that says "ruff", another that says "woof", one that says "yip yip, one that says "bow wow", and finally, one that says "yo quiero Taco Bell". Then, you would have a property called word that would be defined in the following way:
    private String word;
    public void setWord(String word) { this.word = word; }
    public String getWord() { return word; }Then, using your favourite Bean box or design tool, you would create several dogs, and set the word differently for each one.
    The code for speak would be this:
    public void speak() { System.out.println(word); }The benifit provided using the beans conventions of getXxx and setXxx allows the Bean Box to determine that there is a property called word, and that you can set this property to allow you to change the word that is spoken without overwriting the speak method.
    I'll say this again, becuase this is important: Anything that can be done with beans can be done without. The advantage to using beans is that a tool like a bean box, or the Introspector class, can dynamically determine which fields provided by a class are intended for use by another external class, AND which methods are used to set or retrieve the values of those fields.
    For example, you could define the same property with the following code:
    public String word;
    public void changeToNewWord(String word) { this.word = word; }
    public String whatDoesItSay() { return word; }The problem with this code, however, is that an introspector or bean box would have ABSOLUTELY NO IDEA that the changeToNewWord method is the method that should be called to set the property word.
    That's the basic idea. It goes much further than this, as you can then define events, such as the SawAnotherDogEvent that cause the bean to call the method speak. Also, you could create a custom bean info class that would tell the introspector that the changeToNewWord method was the setter method for word. The whole point is to provide extra information about you're class so that it can be recognized by some other coding as certain types of fields.
    To find out more, there is an excellent tutorial for Beans on the java developer website (java.sun.com), and the Beans specification is also there. Hope this helps you out. Good Luck!

  • How to use JavaBeans when the number of inputs is variable

    I have a problem. The number of textboxes in a HTML form is read from a database. How can I avoid reentry from users? Is it possible to use JavaBeans or may be there is some other way? Thanks in advance.

    Well, I meant that when a Jsp page is generated the number of textboxes is read from the database. So it it is apriory unknown. But I have found a solution to this problem: create a bean of String type for each textbox. Thanks.

  • Using JavaBeans in a JSP Page

    I wan't to know the advantages and disadvantages of using JavaBeans in a JSP page.
    Like for example general traditional approach for a database connection
    is to create a connection and access the database from that and close the connection
    at the end of the page, instead of the If I use a common connection bean for making connections,
    is that suggestable and then when should i close the connection then.
    One good application of JavaBeans is using a Set and Get methods for form fields in
    a registration form to get back the values.
    So may i know how best can we use the JavaBeans other than this application.
    ThanX in advance,
    kiran
    [email protected]

    I believe putting processing and query code in the JavaBean was one of the reasons for putting JavaBeans support in JSP in the first place. The original idea was to use the setXXX methods to populate the bean's data from the posted form, then do the processing (or database query), then use the getXXX methods to display the bean's data.
    Efficiency-wise, it's exactly the same as putting all the code in-line in the JSP page (actually, it might be a bit slower, because of the reflection required to do it.) Code-wise though, it makes the JSP easier to read.
    Of course, we have EJBs now too, which tie very closely and can match database queries almost one-to-one, one way to incorporate these is inside the JavaBean you reference from the JSP, another way from a servlet you redirect the JSP to, etc...

  • How to use javabean in forms e.g.Jcalender in forms?

    hey all....
    I am using FORMS 10G and java plug-in 1.4.2 for adding javabean in forms and fallowing changes
    1) Installed JRE 1.4
    2)copied Jcalender.jar in /forms/java
    3)edit /forms/server/formsweb.cfg as fallows
    baseHTMLjpi=basejpi.htm
    archive=frmall.jar,Jcalender.jar
    jpi_download_page=http://java.sun.com/products/archive/j2se/1.4.2_06/index.html
    jpi_classid=clsid:CAFEEFAC-0014-0002-0000-ABCDEFFEDCBA
    jpi_codebase=http://java.sun.com/products/plugin/autodl/jinstall-1_4_2-win.cab
    jpi_mimetype=application/x-java-applet;jpi-version=1.4.2
    4)load module Jcalender.fmb in form builder
    5)Register the path of 'Jcalender.jar' file where it is stored, in 'FORMS_BUILDER_CLASSPATH'
    5)import java class 'Jcalender.jar' from Program in menu bar
    6)Then it give an exception
    Importing Class oracle.forms.fd.Jcalender...
    Exception occurred: java.lang.UnsupportedClassVersionError: oracle/forms/fd/Jcalender (Unsupported major.minor version 49.0)
    help will be appreciated..plz
    Thank in advance..

    Hi..
    Thanks 4 ur suggestion.
    I am using forms 10.1.2.0.2.i am compiling it on my local m/c.
    Jcalender is not working but the method of all javabean is almost same.
    i can use laf.jar with template 'laf_template.fmb.
    will u plz tell me the steps to use javabean(with plugin ) and suggest the version.
    thanks a lot. Expecting reply..
    bye..

  • Using javabean in tomcat(unable to compile class)

    Hello, I am using jakarta-tomcat-5.0.28, OS:WinXP
    I am getting the following error when i use javabean in tomcat (the example is executed just fine in another web server:Blazix)
    I am very new to this (JSP, Servlets and tomcat) so any help would be greatly appreciate.
    THE ERROR IS:
    ==============================================================
    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: /SaveName.jsp
    Generated servlet error:
    C:\Programs\internet\jakarta-tomcat-5.0.28\work\Catalina\localhost\JSPSession\org\apache\jsp\SaveName_jsp.java:42: cannot resolve symbol
    symbol : class UserData
    location: class org.apache.jsp.SaveName_jsp
    UserData user = null;
    ^
    An error occurred at line: 1 in the jsp file: /SaveName.jsp
    Generated servlet error:
    C:\Programs\internet\jakarta-tomcat-5.0.28\work\Catalina\localhost\JSPSession\org\apache\jsp\SaveName_jsp.java:44: cannot resolve symbol
    symbol : class UserData
    location: class org.apache.jsp.SaveName_jsp
    user = (UserData) jspxpage_context.getAttribute("user", PageContext.SESSION_SCOPE);
    ^
    An error occurred at line: 1 in the jsp file: /SaveName.jsp
    Generated servlet error:
    C:\Programs\internet\jakarta-tomcat-5.0.28\work\Catalina\localhost\JSPSession\org\apache\jsp\SaveName_jsp.java:46: cannot resolve symbol
    symbol : class UserData
    location: class org.apache.jsp.SaveName_jsp
    user = new UserData();
    ^
    3 errors
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:332)
         org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:412)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
    ===============================================================
    ERROR END
    I use the folowing files:
    GetName.html
    SaveName.jsp
    NextPage.jsp
    UserData.java
    My Dir Structure is:
    /JSPSession
        GetName.html
         SaveName.jsp
         NextPage.jsp
       /WEB-INF
          /classes
             UserData.java
             UserData.class
       /libThe Code for the files is:
    GetName.html
    <HTML>
    <BODY>
    <FORM METHOD=POST ACTION="SaveName.jsp">
    What's your name? <INPUT TYPE=TEXT NAME=username SIZE=20><BR>
    What's your e-mail address? <INPUT TYPE=TEXT NAME=email SIZE=20><BR>
    What's your age? <INPUT TYPE=TEXT NAME=age SIZE=4>
    <P><INPUT TYPE=SUBMIT>
    </FORM>
    </BODY>
    </HTML>---------------------------------------------------------------------------------------------------
    SaveName.jsp
    <jsp:useBean id="user" class="UserData" scope="session"/>
    <jsp:setProperty name="user" property="*"/>
    <HTML>
    <BODY>
    <A HREF="NextPage.jsp">Continue</A>
    </BODY>
    </HTML>-----------------------------------------------------------------------------------------------------
    NextPage.jsp
    <jsp:useBean id="user" class="UserData" scope="session"/>
    <HTML>
    <BODY>
    You entered<BR>
    Name: <%= user.getUsername() %><BR>
    Email: <%= user.getEmail() %><BR>
    Age: <%= user.getAge() %><BR>
    </BODY>
    </HTML>------------------------------------------------------------------------------------------------------------
    UserData.java
    public class UserData {
        String username;
        String email;
        int age;
        public void setUsername( String value ) {
            username = value;
        public void setEmail( String value ) {
            email = value;
        public void setAge( int value ) {
            age = value;
        public String getUsername() { return username; }
        public String getEmail() { return email; }
        public int getAge() { return age; }
    }

    A very common question. Tomcat dislikes classes which are not packaged. So, add a package statement in your UserBean.java
    package beans; // or something like thatand then place the compiled class file UserBean.class into WEB-INF/classes/beans.
    Put the import statement into the JSP accordingly and try again.
    ***Annie***

  • How to use JavaBean in Form Builder 6i

    Hi,
    How to use JavaBean in Form Builder 6i (Oracle Developer 6i)?.
    i'am using Oracle Sever 8.0.4 and Oracle Developer 6i.
    Please give your valuable suggestion
    Regards
    Seema

    I would suggest you start with the sample Java bean code we have
    on otn.
    http://otn.oracle.com/products/forms
    go to the sample code section.

  • What is the difference of using JavaBean and regular classes?

    Experts,
    I am new to JavaBean(not EJB), and wondering what is the difference of using JavaBean for JSP page compared with using regular Java class?
    I know there are Bean tags which save some lines, what else?
    What does "serialization" mean compared with "not serializable"?
    thanks very much.

    No.
    A JavaBean is a regular JavaClass that:
    1) implements java.io.Serializable
    2) Its data members are private, and its data is accessed via getters and setters. You must define the getters and setters. Getters retrive the property, and must be in the format:
    public PropertyType getPropertyName()
    for most cases. The exception is when the PropertyType is a boolean, in which case you use:
    public boolean isPropertyName()
    Setters assign values to the property, and are in the form:
    public void setPropertyName(PropertyType propValue)
    3) There is also a PropertyChangeEvent model that needs to be followed.
    A marker interface has no methods you need to implement. It just marks the class as supporting certain operations. In the case of Serializable, it means the class can be written to be an ObjectOutputStream for persistant storage.
    As far as an example of JavaBean persistance, take a search on the java.sun.com site for Serializeable
    Also, take a look at this: http://java.sun.com/developer/onlineTraining/Beans/beans02/
    It concentrates mainly on gui component beans, but not all beans need to be gui parts... There are other pages to look at, but I can't find them at the moment, and I have to run...

  • Using javabean

    I try to use javabean
    after I compile the javabean and put the class file at WEB-INF\lib
    but I get errors like below at jsp page
    ( I use sun java studio as tool ,is there any reference )
    testpage_jsp_jsp.java [67:1] cannot resolve symbol
    symbol : class simpleMath
    location: class jsps.test_page_jsp_jsp
    simpleMath pagecounter = null;
    ^
    testpage_jsp_jsp.java [70:1] cannot resolve symbol
    symbol : class simpleMath
    location: class jsps.test_page_jsp_jsp
    pagecounter= (simpleMath)
    ^
    testpage_jsp_jsp.java [75:1] cannot resolve symbol
    symbol : class simpleMath
    location: class jsps.test_page_jsp_jsp
    pagecounter = (simpleMath) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "simpleMath");
    ^
    thanks for the help

    class file go into WEB-INF/classes
    You also should packages and import the classes into your jsp

  • Dynamic UI using JavaBeans?

    Hi,
    Several years ago I created a Windows application where the complete UI was dynamically created depending upon the ActiveX components that the container application found registered on the system.
    Does anyone know if this kind of thing can be achieved using JavaBeans ?
    I have a feeling that it can, but I cannot find any documentation or samples of this kind of thing being done.
    To this end I have a couple of questions. Any help would be greatly appreciated.
    1. Does anyone know how a Java container client application can detect which beans are "registered" on the system.
    2. Is there even a "registration" even for beans ?
    3. How about "un-registering" beans ?
    4. Given that a registered bean CAN be detected by the application, can the bean make modifications to the container, for example, adding menu and toolbar items specific to that bean?
    Thanks
    FC

    Several years ago I created a Windows application
    where the complete UI was dynamically created
    depending upon the ActiveX components that the
    container application found registered on the system.Arranged in what manner? If I had a Button ActiveX component "registered" on my system, how would it know that my current UI needed ten buttons? How would it lay them out in the panel?
    Does anyone know if this kind of thing can be achieved using JavaBeans ?Registration = Windoze registry? There's the Preferences API.
    I have a feeling that it can, but I cannot find any documentation or samples of this kind of thing being
    done.
    To this end I have a couple of questions. Any help
    would be greatly appreciated.
    1. Does anyone know how a Java container client application can detect which beans are "registered" on
    the system.I'd be able to answer if I understood what "registered" really meant.
    2. Is there even a "registration" even for beans ?See previous answer.
    3. How about "un-registering" beans ?See previous answer.
    4. Given that a registered bean CAN be detected by the application,
    can the bean make modifications to the
    container, for example, adding menu and toolbar items
    specific to that bean?I don't see how a Bean can know how to modify ten completely different containers. A single registration can't possibly handle every disparate UI that comes along.
    You sound like you need something along the lines of a UIBuilder class that could take some kind of descriptor and create a UI panel from it. That descriptor could be held in a properties or XML descriptor file as well as a registry. The UIBuilder would have to read the descriptor and pump out the UI panel that you wanted.
    Perhaps I don't understand the Windoze registry that you're talking about, but I don't see how it can possibly handle arbitrarily complex UIs.
    Somebody else was just asking about this kind of thing yesterday. I'll see if I can find the link.

  • How Do I Present Result of Multiple Rows Using JavaBean

    How do I present to my users multiple rows that returned by a query using JavaBean?

    Well you're getting everything back in a ResultSet, right? It's not really a good idea to do much with that ResultSet beyond taking all the data it contains and sticking it in some other sort of data structure. ResultSets rely on a connection to retrieve the data, and once the connection is lost, so is the data they contain.
    So, if you have a ResultSet that contains the results of a query on a table, let's say Users, then you could put the results into a collection of some sort.. Vector maybe... and return that Vector. Then you could loop through your Vector to display multiple rows to the user.

  • How to use JavaBeans as Datasource for Crystal Report 10?

    I have tried to use Crystal Report 10 with Java Beans as Data Source.
    I read
    http://support.businessobjects.com/communityCS/TechnicalPapers/cr10_java_bean_datasource.pdf
    and followed all steps to use JavaBeans as a DataSource.
    I have setup all registry entry requiered for it but still getting blank dialog box for Java Beans Connectivity classes?
    If anyone have tried to use, then give suggestions.

    I have tried to use Crystal Report 10 with Java Beans as Data Source.
    I read
    http://support.businessobjects.com/communityCS/TechnicalPapers/cr10_java_bean_datasource.pdf
    and followed all steps to use JavaBeans as a DataSource.
    I have setup all registry entry requiered for it but still getting blank dialog box for Java Beans Connectivity classes?
    If anyone have tried to use, then give suggestions.

  • Use JavaBean in Tomcat4.0

    Hi all!!!!
    I wanna use JavaBeans in my JSP page, but I dont know how to locate my beans.
    I put my jsp-page in the ..\webapps\ROOT\, and I try to put my beans in the \webapps\ROOT\WEB-INF\classes\.But I got the following message...
    org.apache.jasper.JasperException: Unable to compile class for JSPerror: File E:\tomcat\webapps\ROOT\WEB-INF\classes\user\Select.class does not contain type user.Select as expected, but type Select. Please remove the file, or make sure it appears in the correct subdirectory of the class path.
    Plz help me....thanx alot!!!!!!

    For this example the web root is at c:\web, and the bean class file is SimpleBean.java and the package name is FoobarPackage.
    Step one, put your java file/s into the package. At the top of your java file put "package FoobarPackage;"
    Step two, put all your java files at c:\web\WEB-INF\classes\FoobarPackage\
    Step three, compile.
    Step four, restart tomcat.
    Step five, make a jsp page and place it at c:\web. In your jsp page to load the bean you place the following in your page.
    <jsp:useBean id="TheBean" scope="whatever you want" class="FoobarPackage.SimpleBean" />
    Step six, create a context mapping in your tomcat config file to c:\web to host your files.
    Step seven, load the page in your browser.
    -S-

  • [svn] 1313: Fix for the use namespace problems we've been having with ASC ( I hope).

    Revision: 1313
    Author: [email protected]
    Date: 2008-04-20 09:41:41 -0700 (Sun, 20 Apr 2008)
    Log Message:
    Fix for the use namespace problems we've been having with ASC (I hope). The problem was that the use directive was being defined after we had called finish package. The UseDirectiveNode has a pkgdef ptr, and does different things depending if that ptr is null or not. It should not be null when the UseDirective is inside the package - but since we were generating the UseDirectiveNode after we had called finishPackage the UseDirectiveNode didn't have it's pkgdef ptr set, and so things went awry as the package didn't get set up with all the correct open namespaces. I haven't tested this in authoring/flex but I am pretty sure that this will fix all the problems we're seeing.
    Modified Paths:
    flex/sdk/trunk/modules/asc/src/java/macromedia/asc/parser/Parser.java

    Many thanks.
    With those symptoms, I'd try the following document:
    Apple software on Windows: May see performance issues and blank iTunes Store
    (If there's a SpeedBit LSP showing up in Autoruns, it's usually best to just uninstall your SpeedBit Video Accelerator.)

Maybe you are looking for

  • Want to add a new field in VA05N

    Hi, I would want to add an extra field Employe responsible in VA05N.This field is populated at the time of sales order creation in the partner tab. Is there any way I can add this field in the output layput of VA05N transaction?

  • Re: Asset Issue

    Hi All, Can any one tell me. my user has done asset transfer for that they are maitaining depreciation key Sum of the year digit/acq value, but system  shows straigth line method why its seems calculate in straigth line method. thanks venkat.

  • Transfer rules - Removing invalid hex chars

    Hi,  tried using REGEX command replacing all '\W' with spaces to remove an invalid character (horizontal tab) from a Description field. However the result didnt leave a space but condensed the characters that were either side of the offending charact

  • Is there a way to set a default wifi device, e.g. mobile on IPAD2 please?

    Hi Guys, Can anyone help with a way to set a wifi device as a default.  e.g.  I use my mobile phone through the day to access wifi and want this wifi to be the default.  Any suggestions would be helpful. thanks.

  • My iphone 4 stopped uploading to icloud

    My iphone 4 has suddenly stopped backing my photos up to my icloud, I have bought more memory but still it won't either automatically or manually. Can anyone suggest the answer to this problem.