Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need help in EL and JSP

 
Puja Verma
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From last couple of days i stuckup with some topics. Here they are:

1. I am trying to implement that PERSON-EMPLOYEE example. I hav created one abstract PERSON class and one EMPLOYEE class extending PERSON.

From my jsp program, i am trying to access the PERSON attribute thru employee class but i cant do that . Can you help me out why this is happening.

2. I am trying to implement simple EL : eg. my form is like
<html>
<body>

<h1 align="center"> Employee Information Form </h1>
<form method="POST" action="result.jsp">

Name : <input type="text" name="empName">
ID# : <input type="text" name="empID">
food1 :<input type="text" name="food">
food2 :<input type="text" name="food">


<input type="submit" name="Submit">

</form>
</body>
</html>


and JSP is
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<HTML>

<BODY>


id is : ${param.empID}
food is : ${param.food}
</BODY>
</HTML>

but m not getting value of food and empID. What could be the reason for tat??

thanks,
Pooja
 
Amit K Singh
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Puja,


but m not getting value of food and empID. What could be the reason for tat??


I tried out your scr (JSP/HTML) in tomcat 5.0
It works perfectly fine.

please give more info regd the output on the screen.
Are you able to invoke "result.jsp" ??
Give more information.
 
kumari Jain
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi puja,
The problem could be that EL expressions are not recongnized.
try explicitly setting isELEnabled attribute to true in page directive
ie.add this to your result.jsp

<%@ page isELEnabled="true"%>

Regarding your first topic ,Person Employee problem please provide the
code for better understanding of the problem

regards,
kumari
 
Puja Verma
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Amit ,
Well Here is my JSP :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page isELIgnored="false" %>
<HTML>
<BODY>
id is : ${param.empID}
food is : ${param.food}
</BODY>
</HTML>

and my Form:

<html>
<body>

<h1 align="center"> Employee Information Form </h1>
<form method="POST" action="result.jsp">

Name : <input type="text" name="empName">
ID# : <input type="text" name="empID">
food1 :<input type="text" name="food">
food2 :<input type="text" name="food">


<input type="submit" name="Submit">

</form>
</body>
</html>

and M getting output as :
id is : ${param.empID} food is : ${param.food}



If I am adding <%@ page isELEnabled="true"%> then in that case i am getting error as

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: /result.jsp(2,0) Page directive has invalid attribute: isELEnabled
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:83)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:363)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:233)
at org.apache.jasper.compiler.JspUtil.checkAttributes(JspUtil.java:334)
at org.apache.jasper.compiler.Validator$DirectiveVisitor.visit(Validator.java:148)
at org.apache.jasper.compiler.Node$PageDirective.accept(Node.java:505)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2017)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2059)
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2065)
at org.apache.jasper.compiler.Node$Root.accept(Node.java:423)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2017)
at org.apache.jasper.compiler.Validator.validate(Validator.java:1453)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:264)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:458)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:444)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:593)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:300)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:293)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:288)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:263)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:561)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1018)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:196)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:561)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1018)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2748)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:186)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:561)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1018)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:561)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1018)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:199)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:630)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:463)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:568)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:631)
at java.lang.Thread.run(Unknown Source)
.....................................................................................................
 
Shivani Chandna
Ranch Hand
Posts: 380
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no directive attribute called isELEnabled...

You should use isELIgnored=false.

Alse check in your web.xml which version is specified - it should be 2.4
Paste the header text in your web.xml over here.

Are you using tomcat 5.x version....

Check the above,
Regards.
Shivani
 
Puja Verma
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Shivani ,

First of all thank you so much ....

The problem was with xml version only. Actually i am using WASAD tool for developing my applications and in that, i was getting error, when i was specifying "version " field.
This time i did what you told me and i got the output.


I am now happy that i can test all my EL pending codes.....
thanks,
Pooja
 
kumari Jain
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oops !! error noted.isELIgnored=false is the correct attrribute to be used.sorry for the blunder.

regards,
kumari
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic