tags:

views:

132

answers:

3

I am working on the front end of a jsp based app. We're using spring running on weblogic.

I have a page with a form that submits to itself and I am trying to access the values of hidden fields that I set with javascript.

 <form method="post">

  <input type="hidden" name="choosenDateFrom" value="test1" />
  <input type="hidden" name="choosenDateTo" value="test2"  />
.... more code

However when I use the code on the same page:

 <c:choose>
  <c:when test="${param.choosenDateFrom!=null}">
   <c:out value="${param.choosenDateFrom}" />
 </c:when>
   </c:choose>

The params are not shown on the page. What am I missing? I though this is the standard way of doing this.

Could it be that since we are using a MVC framework I can't pass params around like this?

+1  A: 

Do you have JSTL installed in webapp and declared in JSP?

Check the generated HTML output (open page in browser, choose View Source). It should contain no traces of any JSTL code. If it does, then you likely just need to install JSTL first. Just drop jstl-1.2.jar in webapp's /WEB-INF/lib and declare the taglib in top of JSP as per the JSTL core TLD:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

If that still doesn't solve the problem, then there's apparently means of a brand new request (i.e. a redirect has occurred), or you were using wrong parameter names. Use <c:out value="${pageContext.request.parameterMap}" /> to see all names.

As per your doubt:

Could it be that since we are using a MVC framework I can't pass params around like this?

That purely depends on which one you're using. Not mentioning it doesn't help us to give better answers. But in general the ${param} should be left untouched.

BalusC
yes we have the include<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>What else could I be missing...
Chris Tek
We're using Spring
Chris Tek
How does the generated HTML output look? Have you checked it at any way?
BalusC
html is fine, no traces of jsp, there could be a redirect happening here
Chris Tek
javax.servlet.jsp.el.ImplicitObjectELResolver$ImplicitObjects$5@5956375 is what gets printed out in the html when I use <c:out value="${param}" />
Chris Tek
Oh yeah, I incorrectly expected it to be a `Map`. Do a `${pageContext.request.parameterMap}` instead. Anyway, if there's means of a redirect, then the initial request, including all of its parameters and attributes are obviously unavailable in the redirected request.
BalusC
A: 

have you included the core lib in your jsp? Most of the the cases that what happens and jsp just ignores your syntax.

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
Teja Kantamneni
A: 

You may want to use Firefox plugin named Tamper Data to see if your parameters are actually being posted correctly. Verify that you are not doing a redirect after post because you would loose all your parameters since it asks the browser to perform a new request.

svachon