JSP + Javabeans

When i use a javabean in my jsp it doesnt find my class, I need to put anything in web.xml?? Im using Tomcat 4.0
I have beans.jsp:
<jsp:useBean id="languageBean" scope="page" class="LanguageBean">
     <jsp:setProperty name="languageBean" property="*"/>
</jsp:useBean>
<html>
     <head>
          <title>useBean action test result</title>
And LanguageBeans.class in web-inf/classes/LanguageBean.class
what must I put in web.xml?
Thanks,
Daniel

Actually Tomcat can found the three files, but Im getting an error, and I think the code is good, because is an example from a book.
I have 3 files:
     - beans.html          -->Root
     - beans.jsp     -->Root
          This the first part of the file:
               <jsp:useBean id="languageBean" scope="page" class="LanguageBean">
                    <jsp:setProperty name="languageBean" property="*"/>
               </jsp:useBean>
               <html>
                    <head>
     - LanguageBean.class -->WEB-INF/classes/
This is the error I'm getting:
Apache Tomcat/4.0.6 - HTTP Status 500 - Internal Server Error
type Exception report
message Internal Server Error
description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
An error occurred at line: 1 in the jsp file: /beans.jsp
Generated servlet error:
C:\Program Files\Apache Tomcat 4.0\work\Standalone\localhost\_\beans$jsp.java:56: Class org.apache.jsp.LanguageBean not found.
LanguageBean languageBean = null;
^
An error occurred at line: 1 in the jsp file: /beans.jsp
Generated servlet error:
C:\Program Files\Apache Tomcat 4.0\work\Standalone\localhost\_\beans$jsp.java:59: Class org.apache.jsp.LanguageBean not found.
languageBean= (LanguageBean)
^
An error occurred at line: 1 in the jsp file: /beans.jsp
Generated servlet error:
C:\Program Files\Apache Tomcat 4.0\work\Standalone\localhost\_\beans$jsp.java:64: Class org.apache.jsp.LanguageBean not found.
languageBean = (LanguageBean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "LanguageBean");
^
An error occurred at line: 12 in the jsp file: /beans.jsp
Generated servlet error:
C:\Program Files\Apache Tomcat 4.0\work\Standalone\localhost\_\beans$jsp.java:94: Class org.apache.jsp.LanguageBean not found.
out.print(JspRuntimeLibrary.toString((((LanguageBean)pageContext.findAttribute("languageBean")).getName())));
^
An error occurred at line: 15 in the jsp file: /beans.jsp
Generated servlet error:
C:\Program Files\Apache Tomcat 4.0\work\Standalone\localhost\_\beans$jsp.java:101: Class org.apache.jsp.LanguageBean not found.
out.print(JspRuntimeLibrary.toString((((LanguageBean)pageContext.findAttribute("languageBean")).getLanguage())));
^
An error occurred at line: 18 in the jsp file: /beans.jsp
Generated servlet error:
C:\Program Files\Apache Tomcat 4.0\work\Standalone\localhost\_\beans$jsp.java:108: Class org.apache.jsp.LanguageBean not found.
out.print(JspRuntimeLibrary.toString((((LanguageBean)pageContext.findAttribute("languageBean")).getLanguageComments())));
^
6 errors, 1 warning
     at org.apache.jasper.compiler.Compiler.compile(Compiler.java:285)
     at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:548)
     at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:176)
     at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:188)
     at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
     at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
     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:243)
     at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
     at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
     at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
     at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
     at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
     at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
     at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
     at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
     at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
     at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
     at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
     at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
     at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
     at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
     at java.lang.Thread.run(Thread.java:536)
Thanks

Similar Messages

  • JSP, JavaBeans and iPlanet 4.1-  Unable to load JavaBean

    I get the following error when trying to access a JavaBean from a JSP page. I have tried just about everything including using the <@page import /> in the JSP page.
    I can get it to run perfectly in Tomcat 3.2 but it must run in iPlanet 4.1. I think the solution should be fairly simple I just can't find it.
    Any help would be greatly appreciated.
    Thanks.
    The exception is as follows (thrown on running the generatePage.jsp linked from index.jsp).
    [29/Nov/2001:16:50:23] info ( 1364): Internal Info: loading servlet /TechCom/generatePage.jsp
    [29/Nov/2001:16:50:23] info ( 1364): JSP: JSP1x compiler threw exception
    org.apache.jasper.JasperException: Unable to load class JspPageLoader
         at org.apache.jasper.compiler.BeanRepository.getBeanType(BeanRepository.java:183)
         at org.apache.jasper.compiler.GetPropertyGenerator.generate(GetPropertyGenerator.java:97)
         at org.apache.jasper.compiler.JspParseEventListener$GeneratorWrapper.generate(JspParseEventListener.java:728)
         at org.apache.jasper.compiler.JspParseEventListener.generateAll(JspParseEventListener.java:190)
         at org.apache.jasper.compiler.JspParseEventListener.endPageProcessing(JspParseEventListener.java:159)
         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:141)
         at com.netscape.server.http.servlet.NSServletEntity.load(NSServletEntity.java:214)
         at com.netscape.server.http.servlet.NSServletEntity.(NSServletEntity.java:104)
         at com.netscape.server.http.servlet.NSServletRunner.loadServlet(NSServletRunner.java:607)
         at com.netscape.server.http.servlet.NSServletRunner.Service(NSServletRunner.java:357)
    [29/Nov/2001:16:50:23] warning ( 1364): Unable to locate class: D:\Netscape\Server4\docs\TechCom (java.lang.ClassNotFoundException: D:\Netscape\Server4\docs\TechCom)
    [29/Nov/2001:16:50:23] warning ( 1364): Internal error: Failed to load servlet (servlet=/TechCom/generatePage.jsp)

    To solve this problem you have to:
    include <@page import /> tags importing the JavaBean to be used.
    In the classpath of iPlanet include the directory in which your JavaBeans are placed.
    Also in the classpath of iPlanet include the root directory of you web site containing the JSP's. this should then solve the problem.

  • Newbie jsp/javabean

    Hello,
    I'm trying to do my first web app. First I must log a user from a server database. I thought using JSP to display html pages and javabean to contain logic and functions. In my first page there are a login form with a submit button. How can I call a javabean after pressing button and then read a validate property value from it to login again or pass to next form? To call logic procedures must call setproperty method and do anything inside?
    Thanks,
    Julian.

    You do realize that Java runs on the server don't you? So it you want use java to validate, you would have to do this:
    1) submit username + password to a JSP or servlet
    2) inside that JSP or servlet, read the values from the request and validate them using your bean
    3a) if correct, go on
    3b) if not correct, display error message and show login form again
    How to call the javabean depends on what you are using. If you are using scriptlets, simply call the method as if it were a regular java class. If you are using JSTL, you should read up on that right now because learning that by just coding away is far to difficult. Check out the book you can download for free on this website.
    http://www.coreservlets.com

  • Business Delegate- JSP or JSP- JavaBean, which one is better?

    My current approach is to use a struts action to call a business delegate(pojo) which will go to the session facade and get database info then the JSP simply becames a FETCHER(which helps on reusablity since I can use them for many tables), but I also know I could use struts action to just simply forward to a JSP then retrive the info via JavaBean->EjbSessionFacade
    I'm confused which one is better for performance, scalability, maintainability, etc

    Whatever flow you are following is generally used flow and its correct aslo. Dont think its a bad design. One more think you have to look into is, minimize the remote calls as much as possible. Instead of doing many remote calls you can use EJB local object to process all your business logic and finally you can come out using single Remote call for a process. Look after this.. it will improve performance.

  • Is it possible to do this in JSTL / JSP - JavaBean with static properties ?

    javaBean:
    public class Util {
      private static String s;
      public static void setS(String s) { this.s = s; }
      public static getS() { return s; }
    // some other static utilities needed to be called by other classes
    }JSP Page needs to output the value of s (the static value)
    Is it okay for the JavaBean used to have static values and static get and set?

    By the way, the correct way to write your static setS method (without this!) is:
    public static void setS(String s) { Util.s = s; }

  • JSP  JavaBean classpath

              I have a webapp that has a jsp page that calls a javabean.
              ....But the jsp fails because it cannot find the javabean class !?!?!?!
              I am starting weblogic server using the startweblogic.cmd
              script.
              The bean class is in my system classpath and in my my POST_CLASSPATH
              defined my the startup script but its still not working.
              Do I need to add something to my web.xml ?
              Thanks in advance!
              

    Hello,
              Try this,
              Place the bean in weblogic/myserver/serverclasses
              remembering to mainitain the package structure of your bean
              Make sure you are refering to the bean using it's fully qualified name in
              the jsp page
              this should work regardless of your classpath.
              regards hoose
              "George M. Pieri" <[email protected]> wrote in message
              news:[email protected]..
              >
              >
              > I have a webapp that has a jsp page that calls a javabean.
              >
              > ....But the jsp fails because it cannot find the javabean class !?!?!?!
              >
              > I am starting weblogic server using the startweblogic.cmd
              > script.
              >
              > The bean class is in my system classpath and in my my POST_CLASSPATH
              > defined my the startup script but its still not working.
              >
              > Do I need to add something to my web.xml ?
              >
              >
              > Thanks in advance!
              >
              >
              >
              

  • Using HTML, JSP, JavaBeans and Access database

    I'm trying to create a login page that will allow users to query, insert, modify, and delete information. I have an HTML page that the user chooses which option they want to do. I have 4 JSP's set up for each option. My biggest issue is getting them to talk to the database using a single JavaBean. I can create several beans to pull the information, post, delete, or modify. I'm having trouble pulling information through the JSP's from the HTML page. Please help...

    Hey,
    You get html to communicate with your server using forms. Use the request to retrieve the submitted form data. All you would need to do is tell your bean what it is doing, how and with what.
    Good luck

  • JSP JavaBeans and Database

    i am wondering whats the "correct" or best way to connect to a DB using JavaBeans and using this in JSP pages?
    i read abt creating a SQL "Helper" class that has some functions like connect etc... but i am thinking its a bit confusing...
    if i have a function
        public static Statement Connect() {
            try {
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                con = DriverManager.getConnection("jdbc:odbc:auction","","");
                stmt = con.createStatement();
            } catch (SQLException e) {
                System.out.println("ERROR: SQLException occured!\n" + e.getMessage());
            } catch (Exception e) {
                System.out.println("ERROR: An Exception occured!\n" + e.getMessage());
           return stmt;
        }then i use it
    Statement stmt = SqlHelper.connect();when i want to close the connection how do i do it? is it a must to close connections anyway?
    or shld i do it the easy way, having the code
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection("jdbc:odbc:auction","","");
    stmt = con.createStatement();on all JSP pages?
    Thank you

    BalusC wrote:Do it in the data layer. Write DAO classes and SQL helper classes. Then let the business layer, the Servlet, interact with the data layer and let the presentation layer, the JSP, display the results.
    And don't return a Statement, but a Connection. And yes, closing a Connection is a must, otherwise you're leaking resources which will cause your web application to crash due to a memory shortage.ya thats what i am trying to do... but how do i? like this? except i return a connection instead? and also, i shld return it by reference? mmm... in java isit like return &con?
    package AuctionSystem;
    import java.sql.*;
    public class SqlHelper {
        private static Connection con;
        private static Statement stmt;
        public SqlHelper() {
            Connection con = null;
            Statement stmt = null;
        public static void Connect() {
            try {
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                con = DriverManager.getConnection("jdbc:odbc:auction","","");
                stmt = con.createStatement();
            } catch (SQLException e) {
                System.out.println("ERROR: SQLException occured!\n" + e.getMessage());
            } catch (Exception e) {
                System.out.println("ERROR: An Exception occured!\n" + e.getMessage());
        public static Connection getCon() {
            return con;
        public static Statement getStmt() {
            return stmt;
        public static void Close() {
            con.close();
            stmt.close();
        public static String FormatString(String string) {
            return "'" + string + "'";
    }Edited by: iceangel89 on May 27, 2008 3:50 AM

  • JSP, JavaBean, web.xml - how to fit together?

    Servlets should be placed into the web.xml file to be recognized correctly by a application server.
    Is this also true for JavaBeans (NOT Enterprise JavaBeans!)? Since I don't call a JavaBean directly but only over tags within a JSP I'm not sure about this. If I have to put it in there, do I use the same syntax?
    e.g.:
    <servlet>
    <servlet-name>exampleBean</servlet-name>
    <servlet-class>example.exampleBean</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>exampleBean</servlet-name>
    <url-pattern>/exampleBean</url-pattern>
    </servlet-mapping>
    By using this, the will server know that this Bean has to be deployed?
    Since I'm pretty new to this topic I'm grateful about any comment.
    Thanks in advance!

    Hi,
    JavaBean are java classes and they must be on the classpath in order to be loaded.
    only servlet,jsp,filters,listeners must be declared in the web.xml file. all the java classes can be put under /WEB-INF/lib in order to be loaded by the appserver
    hope it helps,
    Giovanni

  • Jsp - JavaBean  Error

    Hi Friends,
    I am stuck with one error in jsp and javabean.
    I have Three file
    1. Home.jsp [ home page]
    2. log.jsp [check user]
    3. connectBean.java [class file is in WEB-INF\classes\connection] connection is my package.
    When i open nd login using user name & password it give 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: /log.jsp(1,5) Invalid directive
         org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
         org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
         org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:88)
         org.apache.jasper.compiler.Parser.parseDirective(Parser.java:499)
         org.apache.jasper.compiler.Parser.parseElements(Parser.java:1426)
         org.apache.jasper.compiler.Parser.parse(Parser.java:133)
         org.apache.jasper.compiler.ParserController.doParse(ParserController.java:216)
         org.apache.jasper.compiler.ParserController.parse(ParserController.java:103)
         org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:167)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:306)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

    Log.jsp
    <%@ language="java" import="java.util.*,java.sql.*" errorPage="" %>
    <jsp:useBean id="chk1" class="connection.ConnectionBean" scope="page" />
    <%
         String userId = request.getParameter("txt_username");          //get user name frm home page.
         String passWd = request.getParameter("txt_password");          //get password frm home page.
         session.setAttribute("userId",userId);      //set session value as user name.
         session.setAttribute("passWd",passWd);          //set session value as password.
         String type = chk1.chkLogin(userId,passWd);          //pass value to ConnectionBean to get user name.
         String userName = chk1.getUserName(userId,passWd);          //pass value to connection bean to get user name.
         if(type.equals("admin") {
              session.setAttribute("msg"," Welcome " + userName+" ..");
              response.sendRedirect("AdminHomePage.jsp");
         else {
         session.setAttribute("msg","Login Failed.....");
         response.sendRedirect("Home.jsp");
    %>
    <html>
    <head>
    <title>Checking</title>
    </head>
    <body>
    Hello
    </body>
    </html>
    Home.jsp
    <%@ page language="java" import="java.util.*,java.sql.*" errorPage="" %>
    <html>T
    <head>
    <title>Home Page</title>
    </head>
    <body>
    <form name="frm_login" action="log.jsp" method="post">
    <table align="center">
         <tr><td>User Name</td><td></td><td><input type="text" name="txt_username" /></td></tr>
         <tr><td>Password</td><td></td><td><input type="password" name="txt_password" /></td></tr>
         <tr><td></td><td><input type="submit" name="btn_login" value="Login"/></td><td></td></tr>
    </table>
    <%
         String msg1 = (String)session.getAttribute("msg");
         if (msg1 != null)
         out.println(msg1);
         session.removeAttribute("msg");      
    %>
    </form>
    </body>
    </html>
    ====
    connectionBean.java
    ackage connection;
    import java.lang.*;
    import java.sql.*;
    import java.util.*;
    public class ConnectionBean {
         Connection con;
         Statement st;
         ResultSet rs;
         // * * For Connection * *
         public Connection getCon() {
         try {
                   Class.forName("org.postgresql.Driver");
                   con=DriverManager.getConnection("jdbc:postgresql://localhost/postgis?user=postgres&password=raj");
                   return con;
              catch(Exception e)     {
                   System.out.println(e);
                   return con;
         //For Check a Specific User And Go To His/Her Home Page
         public String checkLogin(String uName,String passWd) {
              try {
                   con=getCon();
                   st=con.createStatement();
                   rs=st.executeQuery("select * from login_table where userName='"+uName+"' and passWord='"+passWd+"'");
                   if(rs.next()) {
                        String type=rs.getString(5);
                        return type;
                   else
                        return "error";
              catch(Exception e1) {
                   System.out.println(e1);
                   return "error";
    //For Getting User Name
    public String getUserName(String userId,String passWord)
    String userName=null;
    try
    con=getCon();
    st=con.createStatement();
         rs=st.executeQuery("select userName from login_table where userName='"+userId+"' and passWord='"+passWord+"'");
         while(rs.next())
              userName=rs.getString(2);
         return userName;
         catch(Exception e)
         System.out.println("getUserName:"+e);
         return "hiii";
    }

  • Strange thing with tomcat+jsp+javabean

    I use javabean in jsp with tomcat container.if I put the javabean file in a package,then it works well.But if I don't, I means,there are no package clause in my javabean file.then it complaint that org.apache.jsp. error:class not found.
    It is very strange.Of course place the class file I put is right.Do anyone encounter the same problem.I use tomcat4.0.4

    Did you import the classfile? Even if it is not there in a package, you need to import it.
    For example, if you have a Test.java (Test.class) in your web-inf\\classes with out any package statement, then you need to code this in your jsp,
    <%@ page import="Test" %> (I don't exactly remember whether you need to import 'Test' or 'Test.class'). Just give a try.
    Sudha

  • Error - '.' expected - while database insert thru JSP & javabeans & JDBC

    I get the following error when i try to compile the below mentioned code in JDEVELOPER 10.1.2
    Error : '.' expected
    ===================
    have error in my code. I am trying to do a simple database insert program using javabeans and jsp. I get a value to be inserted in database through the jsp page in a text box and would like to be inserted into database using beans The connection to database and mysql query are in java file.
    Here is the code.
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@ page language="Java" import="java.sql.*" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
    <html>
    <head>
    </head>
    <body>
    <form name="form1" action="beancode" method="POST">
    Emp ID: <input type="text" name ="emplid"> <br><br><br>
    <input type = "submit" value="Submit">
    <jsp:useBean id="sampl" class="beancode" scope="page">
    <jsp:setProperty name="sampl" property="*"/>
    </jsp:useBean>
    </form>
    </body>
    </html>
    I know i might have made a mistake here in using the bean. Here is the java code which does the insert part.
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    * @author Trainees
    public class beancode
    private String employid;
    private Connection con = null;
    private ResultSet rs = null;
    private PreparedStatement st = null;
    /** Creates a new instance of beancode */
    public beancode()
    try
              Class.forName("org.gjt.mm.mysql.Driver");
              Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/sample?user=user&password=password");
    catch(Exception e)
              System.out.println(e.getMessage());
    public void setemployid(String empid)
              employid = empid;
         public String getemployid()
              return (employid);
    public void insert()
    try
    String s1="insert into samp values('"+employid+"')";
    st = con.prepareStatement(s1);
    st.executeUpdate();
    st.clearParameters();
    st.close();
    catch(Exception m)
    }

    It's pretty hard to spot any errors the way it's currently formatted. But, you're trying to call the beancode when submitting your form, but the beancode isn't a servlet. Try to find a working example, run it, and then change it to implement your requirements.
    The following example shows you have to use the jstl sql tags: http://www.oracle.com/technology/sample_code/tech/java/codesnippet/jsps/jstlsql.html. If you want to do an insert when a user submits a form, you need 2 pages. The first will contain your form, the second will insert the record.
    (once you've got that running, look for some examples using an mvc framework, and how to use bind variables with jdbc)

  • Database access using HTML, JSP, JavaBean, & Access

    I am trying to create an HTML page that a user logs into and can choose to query, add, delete or modify a specified database. I have created the HTML, the JSP, and access database but I can't figure out how to have 4 different JSP pages(one for each option) to get information from one JavaBean. PLEASE HELP

    http://swforum.sun.com/jive/thread.jspa?threadID=53106&tstart=0

  • JSP-JavaBeans Vote Poll

    I made this thread a year back and I didn't get help that I wanted. I need to create a voting poll that has three choices for computer games that the user can choose from. each of these choices is a radio button. After making a choice, the user clicks vote, which should then show below:
    1)How many total votes have taken place
    2)Display the individual votes for each of the 3 choices and then show a percentage of total votes for each of the 3 choices. The following is an example of what this part should look like:
    Votes: 1 Computer Game 1 Percentage total: 100%
    If there were three votes, one for each of the game choices:
    Votes: 1 Computer Game 1 33%
    Votes: 1 Computer Game 2 33%
    Votes: 1 Computer Game 3 33%
    Total Votes: 3
    This is the format for the project. This is the JSP page I have created so far with no connection to a javabean:
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
    </head>
    <body>
    <table border="1" align="center">
    <tr>
    <td colspan="3" bgcolor="black" align="center"><font color="red" size="3">
    Computer Voting Poll-Erama</font></td></tr>
    <tr>
    <td colspan="3" bgcolor="black" align="center"><font color="red" size="3">
    What is your favorite computer game?
    </font></td></tr>
    <tr><td width="30%" bgcolor="black"></td>
    <td width="40%" bgcolor="black" align="center">
    <input type="radio" name="cgames" value="Oblivion" checked><font color="red" size="2"> Oblivion </font>
    <input type="radio" name="cgames" value="starwars"><font color="red" size="2"> Star Wars: Empire at War </font>
    <input type="radio" name="cgames" value="finalfantasy"><font color="red" size="2"> Final Fantasy XI: Online </font>
    <input type="submit" value="votebutton" name="Vote">
    </td>
    <td bgcolor="black" width="30%"></td>
    </tr>
    <tr><td bgcolor="black" colspan="3" align="center"><font color="red" size="3">
    </font><font color="white" size="3">Total Votes</font></td></tr>
    <tr><td height="15" bgcolor="red" colspan="3"></td></tr>
    <tr><td align="left" bgcolor="black"><font color="white" size="3">0</font></td>
    <td align="left" bgcolor="black"><font color="white" size="3">Oblivion</font></td>
    <td align="center" bgcolor="black"><font color="white" size="3">0.00%</font></td>
    </tr>
    <tr><td align="left" bgcolor="black"><font color="white" size="3">0</font></td>
    <td align="left" bgcolor="black"><font color="white" size="3">Star Wars: Empire at War</font></td>
    <td align="center" bgcolor="black"><font color="white" size="3">0.00%</font></td>
    </tr>
    <tr><td align="left" bgcolor="black"><font color="white" size="3">0</font></td>
    <td align="left" bgcolor="black"><font color="white" size="3">Final Fantasy XI: Online</font></td>
    <td align="center" bgcolor="black"><font color="white" size="3">0.00%</font></td>
    </tr>
    <tr><td height="15" bgcolor="red" colspan="3"></td></tr>
    </table>
    </body>
    </html>
    I have little experience with beans and very little java experience so I'm at a loss for understanding how to make this work. Any examples of code would be very helpful. Thanks.

    Come now, you really don't expect us to believe that you've been working at this for a year with no headway? :)
    Anyway, have you been through the trails that I linked to in your other thread? For JSPs and Servlets? Have a read at the JavaBeans trail [1] while you're at it.
    And if you've got a specific question about some part where you're getting stuck, please post that. Because as of now, it looks like you need help with the whole thing. Please understand that while no one refuses to help you, people will usually not hand out ready made code for you to use. You need to show that you understand what you're doing and have put in effort with your work and are genuinely stuck despite trying.
    Which part are you unable to do? Reading the selected choice? Adding the data to a bean? Displaying the second page?
    [1] http://java.sun.com/docs/books/tutorial/javabeans/
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://www.catb.org/~esr/faqs/smart-questions.html
    ----------------------------------------------------------------

  • JSP, Javabean charset problem

    I have some JSP pages where I try to dynamically present some drop-down
    menus for the users to select values. I use a simple bean to manage it.
    The problem is that those values are in non-iso8859-1 charset and I only
    get ?????? rendered in the select box. I define an array (inline in the
    JSP page as code scriptlet), write all possible (String) options for the
    drop-down menu there and in the bean I do some calculations and render
    the drop-down menu.
    String label[]={"something in iso-8859-7 encoding in here","something in
    iso-8859-7 encoding in here","something in iso-8859-7 encoding in here"};
    and in the bean I have a for-loop to access this.
    The page directive is set to iso-8859-7.
    I think there is some kind of transparent translation, that has to do
    with Java language, and after the rendering I only get ???? instead of
    the correct iso-8859-7 value in the browser.
    Any help appreciated.
    (Tomcat, Apache web server, JDK 1.3,)
    PS: This JSP page is used to submit some data in an Oracle database
    (according to the selection of the user in the drop-down box), so I also
    use JDBC 1.3, but I don't think that's relevant at all with my problem...
    null

    I have some JSP pages where I try to dynamically present some drop-down
    menus for the users to select values. I use a simple bean to manage it.
    The problem is that those values are in non-iso8859-1 charset and I only
    get ?????? rendered in the select box. I define an array (inline in the
    JSP page as code scriptlet), write all possible (String) options for the
    drop-down menu there and in the bean I do some calculations and render
    the drop-down menu.
    String label[]={"something in iso-8859-7 encoding in here","something in
    iso-8859-7 encoding in here","something in iso-8859-7 encoding in here"};
    and in the bean I have a for-loop to access this.
    The page directive is set to iso-8859-7.
    I think there is some kind of transparent translation, that has to do
    with Java language, and after the rendering I only get ???? instead of
    the correct iso-8859-7 value in the browser.
    Any help appreciated.
    (Tomcat, Apache web server, JDK 1.3,)
    PS: This JSP page is used to submit some data in an Oracle database
    (according to the selection of the user in the drop-down box), so I also
    use JDBC 1.3, but I don't think that's relevant at all with my problem...
    null

Maybe you are looking for