0

I am using this html tag in my jsp page . As you see , I want to send sec_id to wall.jsp . but I dont know how exactly can I compare this sec_id with another id that available in wall.jsp in if statement.

<a href= wall.jsp?sec=<%= res.getInt("sec_id")%> > 
Braj
  • 46,415
  • 5
  • 60
  • 76
hdiz
  • 1,141
  • 2
  • 13
  • 27

2 Answers2

0

You can use JavaServer Pages Standard Tag Library or Expression Language that is more easy to use and less error prone.

sample code:

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

<c:set value="XYZ" var="anotherId"></c:set>

<c:if test="${param.sec.equals(anotherId)}">
     Matched
</c:if>

Here param.sec is used to access the value of sec from request parameter.


You can use <c:choose> as well that behave just like a Java Switch statement.

Find more examples...

Community
  • 1
  • 1
Braj
  • 46,415
  • 5
  • 60
  • 76
  • actually I don't test it yet but I realize completely what this code do. i sure test it ;) thanks again – hdiz Aug 07 '14 at 18:42
0

you can even send the data setting it in session

session.setAttribute("sec_id", res.getInt("sec_id"));

In wall.jsp retrieve it from session

int sec_id= session.getAttribute("sec_id");

then compare the two id's like

if(wallJspId==sec_id){
//do something;
}
else{
//do something;
}
SparkOn
  • 8,806
  • 4
  • 29
  • 34