This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
Hello Everybody, Good Morning.I have a small doubt regarding my project.I request you kindly to solve my problem. Now my project is to create a questionnaire with servlets as frontend,JDBC as middleware n Mysql as backend. Suppose that there are several options(it will b fair,if we call them as links) for a user to have a online test say
Now my doubt is that if a user clicks on anyone of the links(java/servlets/jsp) it should link to one common page and the database has to fetch all the questions related to the section they clicked and print the questions on the servlet page i.e if the user clicks on java,he has to get java questionnaire,if the user clicks on JSP he has to get JSP questions and so on
Hope anyone help me in this aspect. Expecting a solution from you, yours thankfully. Ankita.
When you click on any one of these links (Java, JSP, Servlet), call another servlet say, Questionnaire.java which would fetch a parameter as either java or jsp or servlet and then run a SQL query to get all the questions related to the section they clicked and then print the questions on the servlet page. To do this follow these steps: Step 1: Your link shouls have the code like this: <a href="Questionnaire.java?qType=Java">Java</a> <a href="Questionnaire.java?qType=JSP">JSP</a> <a href="Questionnaire.java?qType=servlet">Servlets</a>
Step 2:Fetch parameter in your Questionnaire servlet as:
String qn_type = request.getParamater("qType");
Step 3: Your SQL query to get all the questions related to the section would be:
"SELECT DECSRIPTION, QUESTION, ANSWERA, ANSWERB, ANSWERC,... FROM MYTABLE WHERE SEC='"+qn_type"'";
Step 4: Print the results in the format you want using out.println statements.
So, in thsi way you are having just one comman program being called i.e., Questionnaire.java in the above case..
Hope this solution is helpful.