• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Getting an Exception in JSP code.

 
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

In HFSJ it Pg. No 384 its given that EL renders raw text.includeing HTML.

so i tried below code:

index.jsp
==========


tstServ.java
========


test.jsp
=====


But i'm getting below Exception.


org.apache.jasper.JasperException: An exception occurred processing JSP page /test.jsp at line 14

11:
12: <!--<div class='tipBox'>
13: <b>Tip of the Day :</b> <br/> <br/>-->
14: Tip : ${pageContext.currentTip}
15: <!--</div>-->

Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
foo.tstServ.doGet(tstServ.java:41)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:694)
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:665)
org.apache.jsp.index_jsp._jspService(index_jsp.java:60)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)

root cause

javax.el.PropertyNotFoundException: Property 'currentTip' not found on type org.apache.jasper.runtime.PageContextImpl
javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:193)
javax.el.BeanELResolver$BeanProperties.access$400(BeanELResolver.java:170)
javax.el.BeanELResolver.property(BeanELResolver.java:279)
javax.el.BeanELResolver.getValue(BeanELResolver.java:60)
javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
org.apache.el.parser.AstValue.getValue(AstValue.java:114)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:923)
org.apache.jsp.test_jsp._jspService(test_jsp.java:63)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
foo.tstServ.doGet(tstServ.java:41)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:694)
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:665)
org.apache.jsp.index_jsp._jspService(index_jsp.java:60)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)

Could anyone please help me in resolving what is going wrong in above code.

Thanks in Advance.
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jay,

Please look at this line fro your Exception,

"Property 'currentTip' not found on type org.apache.jasper.runtime.PageContextImpl"

The Exception clearly shows that one currentTip property is not finding which you need in your jsp.

Please try to give this property through your pagecontex.

Please let me know about the same once it done


Thanks,
Hemant
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you set the scoped variable on the request, why would you look for it on the page context?
 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for reply.

Actaully Bear you are right. But when i checked in HFSJ they clearly mentioned that set currentTip in reuqest-scope.

Initially i also find some what awkward but i thought let me just try it.

Hence i tried to set it in request scope.
 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi hemant,

Thanks for your reply.
Actually i'm actually new to the JSP and continue to learning.

Please try to give this property through your pagecontex.



So could you let me know how to achieve above quote?

Thanks in Advance.
 
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


So could you let me know how to achieve above quote?



you cant. Servlet does not have pagecontext reference at all.
 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Balu.

But as Suggested by Bear in earlier reply.
I tried ${pageContext.request.currentTip} also.

but in vain. What is the reason now?

Thanks.

 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jay Shukla wrote:Thanks Balu.

But as Suggested by Bear in earlier reply.
I tried ${pageContext.request.currentTip} also.

but in vain. What is the reason now?

Thanks.



its not ${pageContext.request.currentTip}

use ${requestScope.currentTip}.
 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Balu. It now worked.

But earlier it was menionted in the HSFJ that you can use pageContext object thorught that you can use request and by that you can get the currentTip.

So why it didn't work earlier?


It be better if you explain me this concept briefly.

Thanks a Lot in Advance.

 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I tried ${pageContext.request.currentTip} also.


Creating a scoped variable in request scope does not create a new property on the request.

The request is not the same as request scope (which is a MAP maintained by the request).

You can use pageContext to obtain just about anything in Java code (such as tag handlers and EL functions), but remember that with the EL you are limited to properties and cannot call general functions.
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


So why it didn't work earlier?



${pageContext.request.currentTip} would return request object (can access request parameters and other request methods) , whereas requestScope is specially to access request attributes,
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yeah.. Bear beaten me
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic