Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Pratik Prajapati
JSP EL
0 Answer(s)      2 years and 7 months ago
Posted in : JSP-Servlet


hi! i am developing web app of online exam system. I want to retrive question one by one as the user clicks "next/privious" button.I tried to get questions in arraylist in servlet and than set that arraylist as request attribute and than i wrote EL for that attribute on jsp page.But somehow i dont get any value in output, it gives nothing.What can be the problem.I dont want to use scriptlets.Pls help me to get this solved.

jsp:

<%-- 
    Document   : exam
    Created on : 26 Feb, 2012, 9:20:08 AM
    Author     : Pratik
--%>

<%@page import="java.sql.ResultSet"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"






<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
       <%@page import="dbconnection.Database" %>
<%! int i=1;%>
<form method="post" action=" ">

question is:${questionList[i]}

<tr><td><%=i%></td><td>${questionList[i]}</td>
    <td><input type="radio" value=${Ans1["i"]}  name="radio<%=i%>"${Ans1["i"]}</td>
    <td><input type="radio" value=${Ans2["i"]}  name="radio<%=i%>"${Ans2["i"]}</td>
    <td><input type="radio" value=${Ans3["i"]}  name="radio<%=i%>"${Ans3["i"]}</td>
    <td><input type="radio" value=${Ans4["i"]}  name="radio<%=i%>"${Ans4["i"]}</td>

</tr>

<%
i++;
//}
%>
<tr><td><input type="submit" value="Next"></td></tr>
</table>
</form>



    </body>
</html>

Servlet Code:

package retrive;

import dbconnection.Database;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class retrive_que extends HttpServlet {
 protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
              Database db = (Database) getServletContext().getAttribute("db");
               ResultSet rs=null;
               ArrayList questionList=new ArrayList();
               ArrayList Ans1=new ArrayList();
                ArrayList Ans2=new ArrayList();
                 ArrayList Ans3=new ArrayList();
                  ArrayList Ans4=new ArrayList();
               String fetchque="select * from new_question order by que_no";

        rs=db.runSql1(fetchque);

               while(rs.next())
                {
                 questionList.add(rs.getString(2));

                 Ans1.add(rs.getString(4));
                 Ans2.add(rs.getString(5));
                 Ans3.add(rs.getString(6));
                 Ans4.add(rs.getString(7));
               }
               request.setAttribute("questionList",questionList);
               request.setAttribute("Ans1",Ans1);
               request.setAttribute("Ans2",Ans2);
               request.setAttribute("Ans3",Ans3);
               request.setAttribute("Ans4",Ans4);
        } 
        catch(SQLException e) {
            out.close();
        }
    } 
 protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }

Advertisement
View Answers

Related Tutorials/Questions & Answers:
JSP EL
attribute and than i wrote EL for that attribute on jsp page.But somehow i dont...JSP EL  hi! i am developing web app of online exam system. I want... to use scriptlets.Pls help me to get this solved. jsp: <%-- Document
EL(JSP) - JSP-Servlet
EL(JSP)  Dear Sir, I want to ask that Whether BEA Application server weblogic 8.1 support to Expression language(JSP) or not. Because EL require jsp... version 1.2. I make a program where In Jsp, I want to use EL rather than JSP
Advertisements
EL in jsp - JSP-Servlet
EL in jsp  hai, I tried to test EL operators in my jsp i... for JSP pages delivered with a Servlet 2.4 descriptor is to evaluate EL... can also deactivate EL expression evaluation for a group of JSP pages. Regards
JSP-EL - JSP-Servlet
is: Home.html A simple JSP application EL Uisng In JSP Name...JSP-EL  Dear Sir, I know that this below code run on your system.But Sir, Why the EL code are not executed on my system.I run that code on BEA
JSP-EL - JSP-Servlet
System. Code is: Home.html A simple JSP application EL... ------------------------ Read for more information about EL at: http://www.roseindia.net/jsp...JSP-EL  Dear Sir, I am not able to run that code on my System.On
JSP-EL - JSP-Servlet
JSP-EL  ThankYou Sir for Ur sending the EL example. Sir, I have a JSP-EL problem that not solve by me.. Please review that: That's my program...;Hi friend, Home.html A simple JSP application EL Uisng
JSP-EL - JSP-Servlet
JSP-EL  Dear Sir, You gave me that code: Home.html A simple JSP application EL Uisng In JSP Name... of Expression Language in jsp Hello ${vij.name
EL Implicit Objects
EL Implicit Objects          EL is the JSP 2.0 Expression Language Interpreter from Apache Corporation. EL means the expression language , it makes it possible
Latitude and Longitude of El Salvador
Latitude and Longitude of El Salvador  Hi, What is the Latitude and Longitude on El Salvador? Thanks   Hi, Latitude of El Salvador is:13.8333 and Longitude of El Salvador is: -88.9167 Home to some stunning
EL and Complex Java Beans
EL and Complex Java Beans          EL means the expression language , it makes.... The jsp expression language allows a page author to access a bean using simple syntax
Use of dot(.) operator in EL
Use of dot(.) operator in EL          EL means the expression language , it makes.... The jsp expression language allows a page author to access a bean using simple
EL and complex JavaBeans1
in a jsp page use <jsp:setProperty> standard tag. We are using the EL...EL and complex JavaBeans1          EL means the expression language
Using of [] operator of EL with the Map
Using [ ] operator of EL with the Map          EL expressions are always used... by using the EL . We are retrieving the values of a map firstly by setting the map
Using [] operator of EL with an Array
Using [ ] operator of EL with an Array          EL expressions are always used... length can't be changed.  The [] operator of EL provides us to access
EL Basic Comparisons
EL Basic Comparisons          EL means the expression language , it makes it possible to easily access application data stored in JavaBeans components. The jsp
Request Parameters In EL
Request Parameters In EL          In EL we use "param" attribute... to retrieve the parameters in EL   The code of the program is given below
Catch an Exception using EL
Catch an Exception using EL     ... to catch an exception by using the EL. We can't prevent errors, but of course... we are going to catch an exception using EL in the page where we are going
JSP
Can you explain jsp page life cycle what is el how does el search for an attribute in JSP  Can you explain jsp page life cycle what is el how does el...://roseindia.net/jsp/simple-jsp-example/expressionLanguage.shtml   EL parser
How to Use Java Functions In EL
Descriptor (TLD) File Taglib directive in the jsp page. EL to invoke the function...How to Use Java Functions In EL          To use a Java Functions in  EL we
Conditional Forward using EL
Conditional Forward using EL          We can forward one page to another jsp page... in the html page. In this jsp page we are checking the condition
JSP
WHAT IS EL JSP  WHAT IS EL   EL means the expression... access application data stored in JavaBeans components. The jsp expression...). Before JSP 2.0, we could use only a scriptlet, JSP expression, or a custom
I want to know the all possible syntax for EL code to print the first element of an array.
I want to know the all possible syntax for EL code to print the first element of an array.  Which is the correct EL codes syntax to print the first element of an array named employeeArray. ${employeeArray["0"]} or ${employeeArray
JSP
what are the implicit el objects in JSP  what are the implicit el objects in jsp   Implicit objects in jsp are the objects... and are created at the conversion time of a jsp into a servlet. But we can pass
JSP
what are the implicit el objects in jsp  what are the implicit el objects in jsp   Implicit objects in jsp are the objects... and are created at the conversion time of a jsp into a servlet. But we can pass
Expression Language in JSP
to include server state in the jsp page output. Expression Language (EL...Expression Language in JSP          EL means the expression language
New Page 1
or EL as it is known is used by JSP developers to access and use application data... EL can't be used. In jsp:useBean In body of a tagdependent tag. When EL... : ${pageContext.request.method} Disabling EL: Following declaration can be used in JSP
JSF Expression Language(EL)
The syntax of the EL expression is : # { expression } It is similar to JSP expression... contains { }curly braces inside it expression resides. But JSP EL starts...Expression Language(EL) In this section, you will get a brief description
jsp - JSP-Interview Questions
jsp  what are the thinks in el (jsp) nesseay to take care wel codeing  Hi Friend, Expression Language (EL), provides a way to simplify expressions in JSP. EL provides the ability to use run-time expressions outside
Advertisements
 

 

 

DMCA.com