Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JSTL Implicit Objects

794117Nov 12 2003 — edited Nov 12 2003
According to the JSTL spec, EL defines a whole lot of implicit objects: pageContext, page, request, session, application, param, params etc etc
However I can't seem to access half of them.
Specifically of interest to me is the params attribute right now. But I want to use the application, session, request ones as well.

I'm using the jakarta JSTL 1.0 on JRun4

Test page:
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ page errorPage="/errorPages/debugError.jsp" %>

<hr>  Tag test
 pageContext = <c:out value="${pageContext}"/><br>
 application =  <c:out value="${application}"/><br>
 request = <c:out value="${request}"/><br>
 param = <c:out value="${param}"/><br>
 param.param1 = <c:out value="${param.param1}"/><br>
 params = <c:out value="${params.param1}"/><br>
 params.param1 = <c:out value="${params.param1}"/><br>
<hr>
Printing parameters using attribute param :
<c:forEach var="app" items="${param}">
param: <c:out value="${app.key}"/>=<c:out value="${app.value}"/><br>
</c:forEach>

Printing values for param1 using attribute params.param1 :<br>
<c:forEach var="app" items="${params.param1}">
param1 value: <c:out value="${app}"/><br>
</c:forEach>
<hr>
Printing parameters using script:<br>
<%
  Enumeration params = request.getParameterNames();
  while (params.hasMoreElements()){
    String paramName = (String)params.nextElement();
    String[] paramValues = request.getParameterValues(paramName);
    for(int i=0; i<paramValues.length; i++){
      %><%=paramName%>[<%=i%>] = <%=paramValues%><br> <%
}
}
%>


I navigate to this page with http://localhost:8101/clearSession.jsp?param1=test1&param1=test2

This results in:
pageContext = jrun.jsp.runtime.JRunPageContext@97aaa6
application = 
request = 
param = org.apache.taglibs.standard.lang.jstl.ImplicitObjects$5@144b624
param.param1 = test
params = 
params.param1 = 

--------------------------------------------------------------------------------
Printing parameters using attribute param :
param1=test

--------------------------------------------------------------------------------
Printing parameters using attribute params.param1 :

--------------------------------------------------------------------------------
Printing parameters using script:
param1[0] = test
param1[1] = test2
Several of the implicit JSTL objects are null (pageContext and param are there, but the others aren't) The params attribute doesn't seem to work at all.

If anyone can shed any light on this behaviour, please help me out. I'm banging my head against the wall in frustration here.

Cheers,
evnafets
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 10 2003
Added on Nov 12 2003
6 comments
265 views