The Artima Developer Community
Sponsored Link

Java Answers Forum
error says missing braces, I think otherwise??

6 replies on 1 page. Most recent reply: Sep 6, 2002 5:00 AM by Preeti

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 6 replies on 1 page
Sid Northfield

Posts: 20
Nickname: northfield
Registered: Aug, 2002

error says missing braces, I think otherwise?? Posted: Sep 1, 2002 12:21 PM
Reply to this message Reply
Advertisement
I am working on a small jsp program to retrieve information from request form. I have done similar things with reguest.getParameter("nameOfParameter"): but getting errors when I try with

Enumeration getParameterNames()
String[] getParameterValues(String paramName)

Please help?

Here is the JSP file called exercise.jsp
<HTML>
<HEAD><TITLE>A JSP that navigates the query string</TITLE></HEAD>
<BODY>
<% Enumeration names = request.getParameterNames();
if(names.hasMoreElements()) {%>
<P>Parameters:
<% while(names.hasMoreElements()) {
String name = (String)names.nextElement(); %>
<P><%= name %>
<UL>
<% String[] values = request.getParameterValues(name);
for(int i = 0; i < values.length; i++) { %>
<LI><%= values%>
<% }%>
</UL>
<% }
} else {%>
There is no query string
}%>
</BODY>
</HTML>

Here is the html file:

<HTML>
<HEAD><TITLE>Sid's Credit Card Information Form</TITLE></HEAD>
<BODY>
<FORM ACTION="exercise.jsp" METHOD="POST">
Sid's Credit Card Information
<P> Name: <INPUT TYPE="TEXT" NAME="name" SIZE="25">
<P> Credit Card Number: <INPUT TYPE="TEXT" NAME="number" SIZE="25">
<P> Credit Card Type:
<SELECT NAME="type">
<OPTION>Visa</OPTION>
<OPTION>Master Card</OPTION>
<OPTION SELECTED>Amex</OPTION>
</SELECT>
<P> Expiration Date:
<SELECT NAME="month">
<OPTION SELECTED>01</OPTION> <OPTION>02</OPTION>
<OPTION>03</OPTION> <OPTION>04</OPTION>
<OPTION>05</OPTION> <OPTION>06</OPTION>
<OPTION>07</OPTION> <OPTION>08</OPTION>
<OPTION>09</OPTION> <OPTION>10</OPTION>
<OPTION>11</OPTION> <OPTION>12</OPTION>
</SELECT>
<SELECT NAME="year">
<OPTION>2000</OPTION> <OPTION SELECTED>2001</OPTION>
<OPTION>2002</OPTION> <OPTION>2003</OPTION>
<OPTION>2004</OPTION> <OPTION>2005</OPTION>
</SELECT>
<P>
<INPUT TYPE="RESET" NAME="Reset" VALUE="Reset">
<INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Submit"></TD>
</FORM>
</BODY>
</HTML>

Here is the error:

Internal Servlet Error:

org.apache.jasper.JasperException: Unable to compile D:\tomcat\jakarta-tomcat-3.3.1\work\DEFAULT\myJSPs\jsp\Hour10\exercise_1.java:1 07: 'catch' without 'try'.
} catch (Exception ex) {
^
D:\tomcat\jakarta-tomcat-3.3.1\work\DEFAULT\myJSPs\jsp\Hour10\exercise_1.ja va:123: 'try' without 'catch' or 'finally'.
}
^
D:\tomcat\jakarta-tomcat-3.3.1\work\DEFAULT\myJSPs\jsp\Hour10\ex ercise_1.java:123: '}' expected.
}
^
3 errors

at org.apache.tomcat.facade.JasperLiaison.javac(JspInterceptor.java:898)
at org.apache.tomcat.facade.JasperLiaison.processJspFile(JspInterceptor.java:733)
at org.apache.tomcat.facade.JspInterceptor.requestMap(JspInterceptor.java:506)
at org.apache.tomcat.core.ContextManager.processRequest(ContextManager.java:968)
a t org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:875)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Inte rceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:5 16)
at java.lang.Thread.run(Thread.java:484)


I have looked and counted the number of opening brackets { and closing brackets } and both tally.

The problem with JSP errors is not like java errors jdk (j2se) where they give a line number????

What else could be the problem?


Javed

Posts: 15
Nickname: javedm
Registered: Aug, 2002

Re: error says missing braces, I think otherwise?? Posted: Sep 2, 2002 2:34 AM
Reply to this message Reply
I saw this problem so many times. This is 'cause the way JSP is translated into a servlet. I am very lazy to give a detailed answer at this point of time. I can give some pointers, open the servlet code generated by ur jsp and try to look for corresponding opening and closing backets.....

cannot key in more..being lethargic..feeling sleepy....

Steve Hind

Posts: 2
Nickname: stefano
Registered: Sep, 2002

Re: error says missing braces, I think otherwise?? Posted: Sep 2, 2002 5:00 AM
Reply to this message Reply
Hi,
the <% =values %>
should be <% =values %>
this may be cause of non-compile

Steve Hind

Posts: 2
Nickname: stefano
Registered: Sep, 2002

Re: error says missing braces, I think otherwise?? Posted: Sep 2, 2002 5:01 AM
Reply to this message Reply
Just noticed that the brackets are stipped
<pre></pre>

Sid Northfield

Posts: 20
Nickname: northfield
Registered: Aug, 2002

Re: error says missing braces, I think otherwise?? Posted: Sep 2, 2002 5:10 AM
Reply to this message Reply
the <% =values %>
should be <% =values %> ????????????????

What do you mean by <pre>

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: error says missing braces, I think otherwise?? Posted: Sep 3, 2002 3:46 PM
Reply to this message Reply
I think he meant this:

> the <% =values %>
> should be <% =values[ i ] %>
> this may be cause of non-compile

Preeti

Posts: 1
Nickname: preeti
Registered: Sep, 2002

Re: error says missing braces, I think otherwise?? Posted: Sep 6, 2002 5:00 AM
Reply to this message Reply
Hi ,

I think there is a '<%' missing out..

in the line

}%>

above
</BODY>
</HTML>

Make it
<% } %>

and try out.

Flat View: This topic has 6 replies on 1 page
Topic: about events Previous Topic   Next Topic Topic: y do we have a primary  class in ejb??

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use