GeeCON Prague 2014*
The moose likes JSP and the fly likes error in jstl while writing c:if Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "error in jstl while writing c:if" Watch "error in jstl while writing c:if" New topic
Author

error in jstl while writing c:if

jyothi sanka
Ranch Hand

Joined: Aug 27, 2001
Posts: 39
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

Joined: Oct 12, 2000
Posts: 5093
instead of 'eq' use ==.
In JSTL that's acceptable to compare Strings, the compiler will translate it into a call to equals() for you.


42
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: error in jstl while writing c:if