File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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

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


and I wrote a jsp

<%@ taglib uri="" prefix="c" %>
<% 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 test="${pref =="Safety"}" >
Our breaks won't look up no matter how bad drive you are
<c:if test="${pref == "Maintance"}">
No Problem you won't have to service these breaks

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?
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.

I agree. Here's the link:
subject: error in jstl while writing c:if
It's not a secret anymore!