wood burning stoves 2.0*
The moose likes JSP and the fly likes Getting an Exception in JSP code. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Getting an Exception in JSP code." Watch "Getting an Exception in JSP code." New topic
Author

Getting an Exception in JSP code.

Jay Shukla
Ranch Hand

Joined: Jun 08, 2008
Posts: 214
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.
hemant Budhewar BamniBk
Ranch Hand

Joined: May 09, 2009
Posts: 33
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
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61224
    
  66

If you set the scoped variable on the request, why would you look for it on the page context?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Jay Shukla
Ranch Hand

Joined: Jun 08, 2008
Posts: 214
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

Joined: Jun 08, 2008
Posts: 214
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.
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


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

Joined: Jun 08, 2008
Posts: 214
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

Joined: Jan 01, 2009
Posts: 874

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

Joined: Jun 08, 2008
Posts: 214
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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61224
    
  66

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

Joined: Jan 01, 2009
Posts: 874



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

Joined: Jan 01, 2009
Posts: 874

yeah.. Bear beaten me
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Getting an Exception in JSP code.