Christopher Tokar
Christopher Tokar

Reputation: 11907

JSP page not reading submitted for values

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?

Upvotes: 2

Views: 884

Answers (3)

BalusC
BalusC

Reputation: 1109132

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.

Upvotes: 2

svachon
svachon

Reputation: 7716

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.

Upvotes: 0

Teja Kantamneni
Teja Kantamneni

Reputation: 17472

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" %>

Upvotes: 0

Related Questions