Help on mysql and jsp

hi i am building a web based questionnaire using JSP and i am trying to store some questions with 4 possible choices and a correct answer in a database so that i can print them out in a browser and anwser them and get the feedback on the ones answered right and wrong
eg....
Question 1:
A Method is invoked with
o Method Call
o Local Variable
o Return Statement
o None of the above
can anyone help me with the database structure on how to do this....
and some tips on how to check the questions answered to the correct answer....thanx

Database:
1. Create a table Called 'Questions' with Qid and QDescription columns. Qid is the primary key.
2. Create a table called 'Answers' with Qid, AnswerId, Answer and AnswerCode columns. Qid is the Foreign Key and refers the Qid in Questions table. AnswerId is the primary key. AnswerCode typically contains A,B,C,and D (and E if at all it is there).
3.Create a table called 'QandA' with Qid and AnswerId columns. Qid is the foreign key and refers to Qid of 'Questions' table, AnswerId is the foreign key and refers to AnswerId of 'Answers' table and combination of Qid and AnswerId is primary key.
Java Bean
1. Create an Info bean QInfo with properties qId, answer1, answer2, answer3 and answer4 plus respective set and get methods.
2.Query the database for some 50 questions and store the push resultset contents into the infobean (i.e, you will create 50 different instances of QInfo bean) and add all these info beans to a Vector.
3.Return this vector to the Caller (either JSP or Servlet).
JSP
1. Execute the getQandA() method of the java bean.
2. Display the contents of info beans onto the browser (Question with sequential numbers and Answers with check boxes);
3.On submission of the page, post the contents to another JSP (preferably to a servlet).
4.Get the question id and the answer code from the request body and cross check them against the QandA and Answers tables.
5.Forward the request to another JSP with the no of right answers. Display the result in this page.
Hope this helps and is not too complecated.
Sudha

Similar Messages

  • Mysql and jsp PLZ PLZ PLZ HELP ME

    Hi >>>>>
    I want to as if there any problem with the fallowing code????
    ===========================================================
    DriverManager.registerDriver(driver);
    Class.forName("org.gjt.mm.mysql.Driver").newInstance();
    conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/ecom","ecomAdmin","ecomAdmin");
    state=conn.createStatement();
    ============================================================
    becoz this code isn`t work and givn`t any Exception er ERROR or any thing .
    so PLZ Tell me what to do ?????

    Since I am not using the same driver I cannot be sure of the problem.
    This is how I make a connection using the com.mysql.jdbc.Driver
    // Set SQL jdbc driver
    String connectionDriver = "com.mysql.jdbc.Driver";
    // Create connection string for local host
    String connectionString = "jdbc:mysql://localhost/passport?user=root&password=xxx";
    // Load database driver
    Class.forName(connectionDriver);
    // Make the actual connection
    Connection sqlCon = DriverManager.getConnection(connectionString);
    I hope this helps
    rykk

  • User error :- mysql and jsp

    hello
    i have configured a user in my sql and when i try to connect with the code the error message appears below
    request help on what the message is trying to say, even after ive supplied username and password in the connect url
    =================================================================
    //sample code
    <%@ page import="java.sql.*" %>
    <%
    String connecturl = "jdbc:mysql://mistry:3306/test,user1,test";
    Connection connection = null;
    Statement statement = null;
    ResultSet rs = null;
    %>
    <html>
    <body>
    <% Class.forName("com.mysql.jdbc.Driver").newInstance();
    connection = DriverManager.getConnection(connecturl);
    statement = connection.createStatement();
    rs = statement.executeQuery("select * from login");
    while(rs.next())
    out.println(rs.getString("firstname ")+ "<br>");
    rs.close();
    %>
    </body>
    </html>
    ========================================================
    //error message
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    javax.servlet.ServletException: Access denied for user ''@'mistry' (using password: NO)
         at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:498)
         at org.apache.jsp.handlelogin_jsp._jspService(handlelogin_jsp.java:81)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:92)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:162)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
         at java.lang.Thread.run(Thread.java:534)
    root cause
    java.sql.SQLException: Access denied for user ''@'mistry' (using password: NO)
         at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2928)
         at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:771)
         at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3649)
         at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1176)
         at com.mysql.jdbc.Connection.createNewIO(Connection.java:2558)
         at com.mysql.jdbc.Connection.<init>(Connection.java:1485)
         at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
         at java.sql.DriverManager.getConnection(DriverManager.java:512)
         at java.sql.DriverManager.getConnection(DriverManager.java:193)
         at org.apache.jsp.handlelogin_jsp._jspService(handlelogin_jsp.java:58)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:92)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:162)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
         at java.lang.Thread.run(Thread.java:534)
    Apache Tomcat/4.1.31

    it seems you have a problem here:
    String connecturl = "jdbc:mysql://mistry:3306/test,user1,test";your better off doing something like this:
              Class.forName("com.mysql.jdbc.Driver").newInstance();
              Connection connection = DriverManager.getConnection(url, username, password);where url is the url to the database in your case "jdbc:mysql://mistry:3306/test"
    and username and password are the username and password to the database......
    that's one thing, the other is that the username and password have to be approved of mysql, i don't think tha's your problem since the error shows that you supplied and empty username
    Message was edited by:
    Octavian

  • MySQL and JSP

    this is my jsp coding.
    <HTML>
    <HEAD><TITLE>Employee List</TITLE></HEAD>
    <BODY>
    <%@ page import="java.sql.*" %>
    <TABLE BORDER=1 width="75%">
    <TR><TH>Segment ID</TH><TH>Market Segment</TH></TR>
    <%
    Connection conn = null;
    Statement st = null;
    ResultSet rs = null;
    try {
    String url = "jdbc:mysql://localhost/cust";
    Class.forName ("com.mysql.jdbc.Driver").newInstance ();
    conn = DriverManager.getConnection(url);
    st = conn.createStatement();
    rs = st.executeQuery("select * from market_segment");
    while(rs.next()) {
    %>
    <TR><TD><%= rs.getString("Segment_No") %></TD>
    <TD> <%= rs.getString("Segment_Desc") %></TD></TR>
    <%
    %>
    </TABLE>
    <%
    } catch (Exception ex) {
    ex.printStackTrace();
    %>
    </TABLE>
    Database not connected
    <%
    finally {
    if (rs != null) rs.close();
    if (st != null) st.close();
    if (conn != null) conn.close();
    %>
    </BODY>
    </HTML>

    i have written a java code and call it into jsp page..however no data is available. but my java code is able to retrive the database information n display it in dos command. so i think there is nothing wrong with the coding nor the JDBC sinc eit can retrieve data out of the database. is there any setting to be done for displaying databse info at web page using jsp?

  • Need help with Tomcat and JSP

    Hi
    I'm a complete beginner with JSP, I have experience with Java, Dreamweaver and HTML, but I'm having alot difficulty understanding JSP.
    I tried doing out some of the tutorial examples but they don't seem to come out right on the browser.
    For Example the Code for Date
    <HTML>
    <BODY>
    <%
    // This is a scriptlet. Notice that the "date"
    // variable we declare here is available in the
    // embedded expression later on.
    System.out.println( "Evaluating date now" );
    java.util.Date date = new java.util.Date();
    %>
    Hello! The time is now <%= date %>
    </BODY>
    </HTML>
    Comes out as
    <% // This is a scriptlet. Notice that the "date" // variable we declare here is available in the // embedded expression later on. System.out.println( "Evaluating date now" ); java.util.Date date = new java.util.Date(); %> Hello! The time is now <%= date %>
    I know this probably really sounds like a stupid question but what could be the problem?

    Those it have to saved on the desktop, or in the Tomcat webapps folder or what?It has to be in a web application under tomcat. The easiest one to get up and running with basic jsp is the webapps/ROOT directory which is where the main index page is.
    [url http://www.coreservlets.com/Apache-Tomcat-Tutorial/]This one is a good basic guide to installing/getting it running.
    Also the tomcat documentation itself is reasonable good. Of specific relevance to you would be [url http://tomcat.apache.org/tomcat-5.5-doc/appdev/index.html]Application developers guide which explains the basic layout/structure of a web application.

  • Mysql and JSP or Servlets

    hi, I would like to know if there is any document on the internet containing these information:
    -how to setup a working MySQL server
    -setup a new database!
    -how to use MySQL databases with java
    -basic information on how to read/add data to a database
    as you see I'm a newbie on SQL! but thanks in advance!
    leonard

    When you download mySql it does come with information about how to install it and use it (including a few hundred pages documenting its implementation of SQL). On the mySql download page you should be able to track down a reference to a JDBC driver you can download separately to connect Java to mySql. It comes with documentation that explains how to use it.

  • Help with servlet and JSP

    I am creating a web application that allows users to submit questions and answers to a database. The users can also specify a number of questions and take a randomly generated test from the questions that have been submitted to the database. Currently, I am having trouble figuring out how to generate the test and then grade it. I was thinking I would use a question page that displayed a random question and its answers, allowed the user to answer the question and submit it, and then have the page reload with a new random question from the database. After the user has answered the number of questions they specified, then it would go to a results page with the percent and grade. I'm having trouble figuring out a servlet for the test generation. Any help would be much appreciated.
    Thanks, Mike
    [email protected]

    Please provide more information on exactly what the problem you are having is.
    For example: The following sentence you provide doesn't really say what the problem is:
    " I'm having trouble figuring out a servlet for the test generation."

  • Help me to convert Java and Jsp Files into WAR File!!!!

    I need someone to help me to convert some java servlet files and jsp files into a WAR file. I need it URGENTLY and I'll be very grateful to anyone who is willing to help me! My email is [email protected] Thanks!!!!

    Are the Oracle JDBC drivers 11g used?
    oracle.jdbc.driver.OracleDriver is not supported in 11g drivers.
    Please replace with:
    oracle.jdbc.OracleDriver

  • Hi frnds i want to help in servlet,java bean and JSP

    hi friends i'm right now in M.SC(IT) and i want to do project in SERVLET,,JAVA BEANS and JSP ,
    so pls give me a title about that
    NOTE: I develop a project in group(2 persons there)
    my email id is : [email protected] , [email protected] , [email protected]

    You cannot pair your iPod to a cell phone, so forget about it.
    The only way you can get free WiFi is to hang out at a Denny's, a Starbucks, or a truck stop, and I don't think your parents would approve....

  • MySQL and J2ME

    Hello.
    I'm building an application for mobile phones that should get data from an mySQL database.
    I would like to know what's the simplest way to do this. The database will be very small. Can I do this directly, doing a query to the database or I have to use PHP or some kind of servlet?
    In case of servlets, do they need to be installed on the server or they're just those JSP files?
    Thanks for the help.
    Wilian Segatto
    Computer Engineering Student
    UNISINOS University
    S�o Leopoldo - RS - Brazil
    Current Projects:
    -Pervasive game:
    moBIO Threat // Disease Control
    Articles (in Portuguese):
    -Paradigma Imperativo versus Paradigma Orientado a Objetos
    -Linguagem de Montagem

    You're not helping me. yes I am.
    You are basically saying to me
    to look for information on Google.
    No I didn't! But I should have. Your question is very vague.
    Let me try again. Your question is not specific to J2ME. Do you understand that?
    So you can do it one of two ways.
    1) Just a normal web page created with whatever. There is no need for a code sample for this. There are many, many examples and tutorials available.
    2) Create a webservice and access it like that.
    I posted the link to Wikipedia because I wanted YOU to read it and then come back and say if you want a webservice or not. If you don't know what a webservice is than that link explains it.
    Can anyone give me specific directions, please?Please refrain from being rude and unpleasant.
    And .jsp = J2EE?
    JSP is part of J2EE yes.
    >
    >
    Wilian Segatto
    Please DESIST from posting your lengthy signature on everyone of your posts Wilian. Thank you.

  • How to convert oracle 9i database to mysql using JSP?

    Dear friends,
    I want to convert oracle 9i database to mysql using JSP technology. Does there anyone who have a hint or some web links about this task? I searched the internet and found all of them are not free and no source code. In fact, what I want to do is really simple, I just want to first, reading the oracle database table structure information and then create the exactly same table in mysql, and then copying all the data in oracle database table to mysql table. But I don�t know how to retrieve the oracle table structure using JDBC. And also I want to retrieve all the tables in the oracle database, so I can choose from them to convert to mysql. It seems that the structure in oracle usually have the tablespace information, I don�t know if I can create database in mysql using this tablespace information. And I don�t know where I can find the information about the functions in JDBC? For example, how to retrieve the table structure? Once I retrieve the table structure and create the exactly same table structure in mysql, then I can fetch all the data in oracle table to mysql table.
    Any hint will be great appreciated!
    Merry Christmas and Happy new year!
    Sammy

    Hi, beattris and rtg54,
    thank you very much for your great help!
    beattris, do you know if there is any such kind of tool free? I am a student and don't want to do commercial product, as you see, my work is very simple, in fact, just as you said, the most important of all is how to get the database structure from oracle schema? do you have any idea about this? or do you know any tool that is open source? so I can learn from it.
    rtg54, I just want to convert the database from oracle to mysql, after that, I can use mysql database as storage instead of expensive oracle database. the problem is that I have some data stored in oracle database and the application is built on oracle, after the convertion, I can use mysql to provide data to jsp or servlet application. I will great appreciate if you can contact with mysql about this problem because I don't know how to contact with them.
    thanks again and happy new year!
    Sammy

  • Define mysql and host connection only 1 place

    Hi everyone,
    For my school project i developed a application using servlets and jsp.
    In every servlet i make a new connection.
    Like this:
    public void doPost(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
            response.setContentType("text/html");
            PrintWriter out = response.getWriter();
            System.out.println("MySQL Connect Example.");
            Connection conn = null;
            String url = "jdbc:mysql://127.0.0.1:3306/";
            String dbName = "cijfersysteem";
            String userName = "vishant";
            String password = "vishant";
            String driver = "com.mysql.jdbc.Driver";But if my host changes for example i need to change it in 10 or more files.
    that is not efficient.
    How can i make the connection in 1 file and require it over every other servlet?
    Thnx in advance for the help everyone.

    If you are using Tomcat or Jetty, you can define JNDI entries like this:
    [http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html#JDBC%20Data%20Sources]
    [http://docs.codehaus.org/display/JETTY/JNDI]
    You should be using resource injection in Glassfish.

  • Urgent help needed in compiling JSP on websphere 6

    we are migrating our app from websphere 5 to 6 version. our app has 2 JSP files. Jsp A and Jsp B...
    Jsp A code
    if(cond met) { <%@ include file = JspB %> }
    Now JSP B code
    <bean:define id='X' />
    when i run the JSP A, it throws compilation error as below..
    Jsp A failed to compile, variable X not resolved
    An error occured in the statically included jsp B
    The same code is running on websphere 5. its giving error on 6. ..Pls help..This is urgent,

    Could you post more details perhaps? Eg. the complete files.
    Also, I would recommend that you consider using the runtime include, <jsp:include ...>, and put your variables in the request scope.

  • Hot swap and JSP debugging for Weblogic in exploded format?

    Hi,
    I'm trying to use JDeveloper for JSF development to be deployed to a weblogic server.
    I must say JDeveloper is a great tool for JSF development as none of the free IDE in the market can do what JDeveloper does.
    However, I have a question on hot swap and JSP debugging.
    I have managed to setup JDeveloper to debug my JSF application deploy to my Weblogic server's applications folder in exploded format.
    I can step through the java code.
    However, I didn't manage to do a hot swap and the break point set in the JSF-JSP does not seems to take effect.
    I would appreciate any advice on the problem.
    Thanks.
    Han Ming

    How did you setup the server to handle exploded format? Appreciate the help. Sorry can't help with your question though.
    Thnx.
    Soni

  • Login Box example and source code on adf struts and JSP

    Dear all..
    I want to make application using ADF struts and JSP using oracle 10g Jdeveloper.
    The user should login into the login box and verify everyone who has right to enter the home.jsp.
    Anybody could help me with the source code as well as the step by step explanation...
    I'm looking forward the help...

    http://www.oracle.com/technology/products/jdev/collateral/papers/10g/reviewer/viewlets/reviewer_struts_viewlet_swf.html

Maybe you are looking for