JSP EL

JSP EL

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);
    }
View Answers

Ads









Related Tutorials/Questions & Answers:
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
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
Advertisements
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
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
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
Version of commons-el>commons-el dependency
List of Version of commons-el>commons-el dependency
Version of el-impl>el-impl dependency
List of Version of el-impl>el-impl dependency
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
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
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
JSP
how can we disable el JSP  how can we disable el   You can disable using isELIgnored attribute of the page directive: <%@ page isELIgnored ="true|false" %>
Artifacts of commons-el
List of Artifacts of commons-el maven depenency
Artifacts of el-impl
List of Artifacts of el-impl maven depenency
Maven Dependency el-impl >> 1.0
You should include the dependency code given in this page to add Maven Dependency of el-impl >> el-impl version1.0 in your project
Maven Dependency commons-el >> 1.0
You should include the dependency code given in this page to add Maven Dependency of commons-el >> commons-el version1.0 in your project
Version of struts>struts-el dependency
List of Version of struts>struts-el dependency
ModuleNotFoundError: No module named 'django-el'
ModuleNotFoundError: No module named 'django-el'  Hi, My Python... 'django-el' How to remove the ModuleNotFoundError: No module named 'django-el' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'el-aap'
ModuleNotFoundError: No module named 'el-aap'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'el-aap' How to remove the ModuleNotFoundError: No module named 'el-aap'
ModuleNotFoundError: No module named 'el-aap'
ModuleNotFoundError: No module named 'el-aap'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'el-aap' How to remove the ModuleNotFoundError: No module named 'el-aap'
ModuleNotFoundError: No module named 'el-aap'
ModuleNotFoundError: No module named 'el-aap'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'el-aap' How to remove the ModuleNotFoundError: No module named 'el-aap'
ModuleNotFoundError: No module named 'El-Cuestionario'
ModuleNotFoundError: No module named 'El-Cuestionario'  Hi, My... named 'El-Cuestionario' How to remove the ModuleNotFoundError: No module named 'El-Cuestionario' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'el-piptest'
ModuleNotFoundError: No module named 'el-piptest'  Hi, My Python... 'el-piptest' How to remove the ModuleNotFoundError: No module named 'el... have to install padas library. You can install el-piptest python
ModuleNotFoundError: No module named 'el-piptest'
ModuleNotFoundError: No module named 'el-piptest'  Hi, My Python... 'el-piptest' How to remove the ModuleNotFoundError: No module named 'el... have to install padas library. You can install el-piptest python
ModuleNotFoundError: No module named 'el-piptest'
ModuleNotFoundError: No module named 'el-piptest'  Hi, My Python... 'el-piptest' How to remove the ModuleNotFoundError: No module named 'el... have to install padas library. You can install el-piptest python
ModuleNotFoundError: No module named 'el-user'
ModuleNotFoundError: No module named 'el-user'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'el-user' How to remove the ModuleNotFoundError: No module named 'el-user
ModuleNotFoundError: No module named 'EL-Status'
ModuleNotFoundError: No module named 'EL-Status'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'EL-Status' How to remove the ModuleNotFoundError: No module named 'EL
ModuleNotFoundError: No module named 'el-user'
ModuleNotFoundError: No module named 'el-user'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'el-user' How to remove the ModuleNotFoundError: No module named 'el-user
jsp
jsp  how jsp translated into servlets

Ads