0

I am developing an application using Hibernate, SERVLET, JSP and using MySql database. table used in my project is BeanRegister.

Here I am facing a problem with use of EL in my jsp page. In this JSP page I want to display some information fetched from database table. Here is my codes for this..

ControllerProfile.java :

import java.io.IOException;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.Query;

public class ControllerProfile extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        if ((request.getParameter("accsub") != null)) {
            if (request.getParameter("accuser") != null) {
                Session session = null;

                SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
                session = sessionFactory.openSession();
                org.hibernate.Transaction tx = session.beginTransaction();


                String i = request.getParameter("accuser");
                String Q = " from BeanRegister where userid= :id ";
                Query query = session.createQuery(Q);
                query.setParameter("id", i);

                List<BeanRegister> profile = query.list();
                request.setAttribute("profile", profile);

                tx.commit();
                session.flush();
                session.close();

                RequestDispatcher dispatcher = request.getRequestDispatcher("profile.jsp");
                dispatcher.forward(request, response);
            } else {
                System.out.println("error");

                RequestDispatcher dispatcher = request.getRequestDispatcher("viewprofile.jsp");
                dispatcher.forward(request, response);
            }
        }
    }
}

Profile.jsp:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        ....
        ....
        <form name="proview" id="proview" action="updateprofile.jsp" method="post" >

            <div align="center">
                <table width="366" border="0" bgcolor="#3333CC">
                    <c:forEach var="pro" items="${profile}">
                        <tr>
                            <td width="171" height="23"></td>
                            <td width="194"><input name="password" id="password" type="hidden" value="${pro.password}"/></td>
                        </tr>
                        <tr>
                            <td width="171" height="23"><div align="center">NAME</div></td>
                            <td width="194"><input name="name" type="text" id="name" value="${pro.name}" readonly="readonly"/></td>
                        </tr>
                        <tr>
                            <td width="171" height="23"><div align="center">USER ID</div></td>
                            <td width="194"><input name="userid" id="userid" type="text" value="${pro.userid}" readonly="readonly"/></td>
                        </tr>
                        <tr>
                            <td width="171" height="23"><div align="center">ADDRESS</div></td>
                            <td><input type="text" name="address" id="address" value="${pro.address}" readonly="readonly"/></td>
                        </tr>
                        <tr>
                            <tr>
                                <td width="171" height="23"><div align="center">GENDER</div></td>
                                <td width="194"><input name="sex" type="text" id="sex" value="${pro.sex}" readonly="readonly"/></td>
                            </tr>
                        </tr>
                        <tr>
                            <td width="171" height="23"><div align="center">MOBILE NUMBER</div></td>
                            <td><input name="number" type="text" id="number" value="${pro.number}" readonly="readonly"/></td>
                        </tr>
                        <tr>
                            <td width="171" height="23"><div align="center">EMAIL ID</div></td>
                            <td><input name="email" id="email" type="text" value="${pro.email}" readonly="readonly"/></td>
                        </tr>

                        <tr>
                            <td width="171" height="23"></td>
                            <td width="185"><input name="password1" id="password1" type="hidden" value="${pro.password1}"/></td>
                        </tr>

                        <tr>
                            <td>
                                <div align="center">
                                    Want To Edit Ur Profile Click Here
                                </div></td>

                            <td >
                                <div align="center">
                                    <input type="submit" name="updateprof" id="updateprof" value="UPDATE" />
                                </div></td>
                        </tr>
                    </c:forEach>  
                </table>
            </div>
        </form>
    </body>
</html>

now, when I am accessing my servlet class it makes a call for profile.jsp. but, the form's text fields display the EL codes as it is in the coding. I am very confused why this is not working.

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
amyay
  • 1
  • 1
  • 1

1 Answers1

0
i think you use Tomcat 7
Tomcat 7 does not come with JSTL jar files by default.
   First, locate the jar files for both JSTL API and JSTL Implementation. They are located on the JSP Standard Tag Library download page. Click into each repository and find the .jar file.

Tomcat 7
           =>Servlet -api-3.0
           =>JSTL-1.2

 refer this link:http://javahelpersin.blogspot.in/2013_01_01_archive.html
gowthaman
  • 983
  • 3
  • 9
  • 9