1

I need to pass a request parameter from one JSP to another JSP page like this:

<a href="cv.jsp?type=alaacv">alaa</a>

However, when I try to access it as below, it doesn't print anything.

<c:set var="selectedCV" value="${type}" scope="request" />
<c:out value="${selectedCV}" />

How is this caused and how can I solve it?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
palAlaa
  • 9,500
  • 33
  • 107
  • 166

2 Answers2

3

You need to access it by ${param} which is an implicit EL object referring to the request parameter map (which is actually a Map<String, String>; if you need the Map<String, String[]> for multi-valued parameters, use ${paramValues} instead).

<c:set var="selectedCV" value="${param.type}" />
<c:out value="${selectedCV}" />

The ${param.type} basically resolves to request.getParameter("type").

You can also just do as below without the need for <c:set>:

<c:out value="${param.type}" />

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
0

You need to pass the given parameter in response object to the second .jsp. How to do that depends on the servlet/framework you are using (unless the framework should somehow do it automatically).

Jawa
  • 2,336
  • 6
  • 34
  • 39
  • I am not using servlet, I know it's easier but right now I need to make simple request form jsp to another jsp page and send parameter through anchor !! – palAlaa Feb 10 '11 at 21:10
  • @Alaa - actually, you *are* using a servlet framework under the hood. The servlet framework underpins JSPs. However, I don't think this answer is on the right track. – Stephen C Feb 10 '11 at 21:32
  • I knew that when jsp:engine parse the jsp page it creates servlet for each page – palAlaa Feb 10 '11 at 22:02