• 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

Error msg : 'pageContext' cannot be resolved in tag file

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

I have my web application deployed on WebSphere Application server 6.0 ,which is running fine.Now my task is to move the web application to tomcat 5.5(also included JDK 1.4 compatibility package), as the code is compiled using jdk 1.4.In one of the tag files , i have used jsp implicit object 'pageContext' , which is giving error.

Code :

pageContext.get ServletContext();

Error in tomcat:

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 60 in the jsp file: /WEB-INF/tags/javascriptdeclarations.tag
pageContext cannot be resolved
57: <![endif]-->
58:
59: <!-- Scripts -->
60: <%= nextgen.webui.framework.aggregator.IncludeController.createJSDeclarations((HttpServletRequest)request,pageContext.getServletContext()) %>
61:


I have been searching for any suggestions in Google ,but remained clueless.Any help would be greatly appreciated.

Thanks in advance
Saikrishna Vuddagiri
 
Ranch Hand
Posts: 180
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not very sure but could you please check if servlet.jar is in your classpath
as PageContext comes from that jar.
 
Sheriff
Posts: 67747
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

saurav sarkar wrote:I am not very sure but could you please check if servlet.jar


There is no need for this. The Servlet jar is automatically provided by Tomcat. It should never be copied anywhere.
 
Bear Bibeault
Sheriff
Posts: 67747
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 are using tag files, that means that you are using JSP 2.0. Why are you putting antiquated scriptlets in a tag file?
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[edit: commentary removed]

Unfortunately "pageContext" is not available as an implicit variable in tag files. You *do* have access to "jspContext", which implements the parent class of PageContext, however I'm afraid this isn't an option for you in this situation, as getServletContext() is not available in jspContext. You might try instead to put this code in a JSP snippet that you pull into your JSP with a <jsp:include>
 
Bear Bibeault
Sheriff
Posts: 67747
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

James Garyson wrote:Unfortunately "pageContext" is not available as an implicit variable in tag files.


pageContext is available within tag files within EL expressions.

JSP 2.0 mechanisms are meant to supplant scriptlets, not work with them. Mixing tags files and other JSP 2.0 mechanisms with scriptlets is bound to create difficulties.
 
James Garyson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:

James Garyson wrote:Unfortunately "pageContext" is not available as an implicit variable in tag files.


pageContext is available within tag files within EL expressions.

JSP 2.0 mechanisms are meant to supplant scriptlets, not work with them. Mixing tags files and other JSP 2.0 mechanisms with scriptlets is bound to create difficulties.



I should have been more clear: pageContext is not available as an implicit variable in a scriptlet, which is where the author was was trying to use it.

Since you are so knowledgeable of EL expressions, please instruct the author on the correct way to achieve the results he is looking for.
 
Bear Bibeault
Sheriff
Posts: 67747
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
Using the pageContext in the EL is the correct way to be doing it. Hence my question to the user regarding why he was not using JSP 2.0 mechanisms -- which, unfortunately, was never answered.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I understand that this is an old post but just want to share my found.

From eclipse IDE, when using the content assist feature, it actually have "application" object which is in ServletContext type.

So, you might want to try out "application.getServletContext()" method.

Cheers
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I solved the problem as follows:



<c:forEach var="a" items="${att}">
<img alt="${a}" src="${a}" />
</c:forEach>
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
pageContext is not readily available in tag file. However PageContext is available througj jspContext( casted from Jspcontext). I usd jspContext and am able to share data between scriptlet and jstl.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic