JSP EL

Ads

 
 

Share on Google+Share on Google+

Pratik Prajapati
JSP EL
0 Answer(s)      5 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);
    }
Ads
View Answers
Ads









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
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
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
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
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 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
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
Version of struts>struts-el dependency
List of Version of struts>struts-el dependency
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 marmalade>marmalade-el-commons dependency
List of Version of marmalade>marmalade-el-commons dependency
Version of marmalade>marmalade-el-ognl dependency
List of Version of marmalade>marmalade-el-ognl dependency
Version of struts>struts-bean-el dependency
List of Version of struts>struts-bean-el dependency
Version of struts>struts-html-el dependency
List of Version of struts>struts-html-el dependency
Version of struts>struts-logic-el dependency
List of Version of struts>struts-logic-el dependency
Version of struts>struts-tiles-el dependency
List of Version of struts>struts-tiles-el dependency
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
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
Maven Dependency struts-el >> 2.3
You should include the dependency code given in this page to add Maven Dependency of struts >> struts-el version2.3 in your project
Maven Dependency struts-el >> 1.1
You should include the dependency code given in this page to add Maven Dependency of struts >> struts-el version1.1 in your project