• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

error in jstl while writing c:if

 
jyothi sanka
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I wrote a html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>

<TITLE>p442.html</TITLE>
</HEAD>
<BODY>
<P><strong>When you buying a car what is most important to you?</strong></P>
<FORM METHOD="POST" ACTION="p442Jstl.jsp">
<INPUT TYPE="RADIO" NAME="btn1" VALUE="Performance"> Performance <BR>
<INPUT TYPE="RADIO" NAME="btn1" VALUE="Safety"> Safety<BR>
<input type="RADIO" Name="btn1" value="Maintance"> Maintance<br>
<input type="submit" value="submit">

</FORM>

</BODY>
</HTML>
and I wrote a jsp

<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<html><body>
<% String Pref = (String)request.getParameter("btn1"); %>
<c:if test="${pref eq "Performance"}">
Now you can stop even if you do drive insanely fast
</c:if>
<c:if test="${pref =="Safety"}" >
Our breaks won't look up no matter how bad drive you are
</c:if>
<c:if test="${pref == "Maintance"}">
No Problem you won't have to service these breaks
</c:if>
</body></html>


while runing this code in Tomcat 5.0 I am geting this error
org.apache.jasper.JasperException: /p442Jstl.jsp(5,34) equal symbol expected.


Can anybody explain me where I did wrong?
Thanks
Jyothi
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
instead of 'eq' use ==.
In JSTL that's acceptable to compare Strings, the compiler will translate it into a call to equals() for you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic