Further advice needed on my last question

Further advice needed on my last question

Dear Experts,

I refer to your last solution regarding my matching codes.

After I tried out your solution, I get alot of errors..

.Netbean IDE
mpiling 1 source file to C:\Documents and Settings\build\generated\classes

C:\Documents and Settings\enter_jsp.java:132: 'catch' without 'try'
} catch (Throwable t) {
^
C:\Documents and Settingsapache\jsp\enter_jsp.java:132: ')' expected
} catch (Throwable t) {
^
C:\Documents and Settingsenter_jsp.java:132: not a statement
} catch (Throwable t) {
^
C:\Documents and Settingsbuild\generated\src\org\apache\jsp\enter_jsp.java:132: ';' expected
} catch (Throwable t) {
^
C:\Documents and Settings\enter_jsp.java:139: 'finally' without 'try'
} finally {
C:\Documents and Settings\enter_jsp.java:43: 'try' without 'catch' or 'finally'
try {
C:\Documents and Settingsjsp\enter_jsp.java:143: reached end of file while parsing
}
7 errors

Here are my codes which I modified but basically followed your logic:-


<%@page import="java.sql.*"%>
<html>
<Body>
<form>
Enter ID:<input type="text" name="id"><input type="submit" value="Submit" style="background-color:#49743D;font-weight:bold;color:#ffffff;">
</form>

<%String id = request.getParameter("id");
if (id != null) {%>
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:PracticalODBC");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("SELECT * FROM parents where strNRICNOME ='" + id + "'");

<table border="1">
<tr>
<th>Parents NRIC No</th>
<th>Parents Name</th>
<th>Subjects to be tutored</th>
<th>Parents Contact No</th>
<th>Location</th>
<th>Tutors NRIC No</th>
<th>Tutors Name</th>
<th>Tutors Contact No</th>
<th>Tutors Location</th>
String sub = "", location = "";
while (rs.next()) {
sub = rs.getString("strSubjectsME");
location = rs.getString("strAddress");
}
ResultSet res = st.executeQuery("SELECT FROM parents, memberparticulars WHERE memberparticulars.strSubject = '" + sub + "' + memberparticulars.strLocation = '" + location + "' and strNRICNOME = '" + id + "' ");
while(res.next()){
<tr>
<td><%=res.getString("strNRICNOME")%></td>
<td><%=res.getString("strFullNameME")%></td>
<td><%=res.getString("strSubjectsME")%></td>
<td><%=res.getString("strContactME")%></td>
<td><%=res.getString("strLocationME")%></td>
<td><%=res.getString("strNRICNO")%></td>
<td><%=res.getString("strTutorName")%></td>
<td><%=res.getString("strContact")%></td>
<td><%=res.getString("strAddress")%></td>
<td><input type=button value="Get" style="background-color:#49743D;font-weight:bold;color:#ffffff;" onclick='info("<%=sub%>","<%=location%>")'></td></tr>
}
}
</table>
} catch(Exception e) {
out.println("An error occurred: " + e);
}
</BODY>
</HTML>

I have tried and tried, putting the try and catch but still can't get it right. I really hope you will advise me the correct way to do it. Once again, thank you very much for your help and patience.
View Answers

June 21, 2010 at 3:27 PM

Hi Friend,

We have modified your code. You haven't close scriptlet tag and braces in few places therefore error occurs.Here is your code:

<%@page import="java.sql.*"%>
<html>
<Body>
<form>
Enter ID:<input type="text" name="id"><input type="submit" value="Submit" style="background-color:#49743D;font-weight:bold;color:#ffffff;">
</form>

<%String id = request.getParameter("id");
if (id != null) {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:PracticalODBC");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("SELECT * FROM parents where strNRICNOME ='" + id + "'");
%>
<table border="1">
<tr>
<th>Parents NRIC No</th>
<th>Parents Name</th>
<th>Subjects to be tutored</th>
<th>Parents Contact No</th>
<th>Location</th>
<th>Tutors NRIC No</th>
<th>Tutors Name</th>
<th>Tutors Contact No</th>
<th>Tutors Location</th>
<%
String sub = "", location = "";
while (rs.next()) {
sub = rs.getString("strSubjectsME");
location = rs.getString("strAddress");
}
ResultSet res = st.executeQuery("SELECT FROM parents, memberparticulars WHERE memberparticulars.strSubject = '" + sub + "' + memberparticulars.strLocation = '" + location + "' and strNRICNOME = '" + id + "' ");
while(res.next()){
%>
<tr>
<td><%=res.getString("strNRICNOME")%></td>
<td><%=res.getString("strFullNameME")%></td>
<td><%=res.getString("strSubjectsME")%></td>
<td><%=res.getString("strContactME")%></td>
<td><%=res.getString("strLocationME")%></td>
<td><%=res.getString("strNRICNO")%></td>
<td><%=res.getString("strTutorName")%></td>
<td><%=res.getString("strContact")%></td>
<td><%=res.getString("strAddress")%></td>
<td><input type=button value="Get" style="background-color:#49743D;font-weight:bold;color:#ffffff;" onclick='info("<%=sub%>","<%=location%>")'></td></tr>
<%
}
%>
</table>
<%
} catch(Exception e) {
out.println("An error occurred: " + e);
}
}
%>
</BODY>
</HTML>

Thanks









Related Tutorials/Questions & Answers:
Further advice needed on my last question - JSP-Servlet
Further advice needed on my last question  Dear Experts, I refer to your last solution regarding my matching codes. After I tried out your... errors Here are my codes which I modified but basically followed your logic
Clarify my last question's answer - Java Beginners
Clarify my last question's answer  Dear expert, I've tried out... did not specify my question too clearly. Here's my 2 database... and parents contain other fields like name, address, email, contact numbers etc. My
Advertisements
further clarification needed - Java Beginners
further clarification needed  Dear Experts, I refer to the last...-University Level. Some tutors will enter more sujbects. So, my query will have to change to %LIKE% is it? How do I include query like that into my query
last question
last question   Input the name and marks of 25 students and compute the average. Print out the name and average of each student. (You can do this using an array or without using an array
my question
my question   "Write a C/C++ program to show the stored procedure PROCRESETMAIL" on database "USER_NOTIFY
my question
my question   "Write a C/C++ program to show the stored procedure PROCRESETMAIL" on database "USER_NOTIFY
solve my question shortly
solve my question shortly  <html> <head> <script> function checkphoneNumber(number){ if(/[^\d ]/.test(number)){ alert('It should contain numbers [0-9] only!'); document.getElementById
my question - EJB
my question  is it possiable to create web application using java beans & EJB's with out implementing Servlets and jsps in that java beans and EJB's
my question is related to my project viz
my question is related to my project viz   Sir, my project is based on MR tracking system developed using struts framework, it has been developed in Net Beans the whole project is working except a jsp page named dayplan.jsp
How to bookmark and preview last question in a java test engine - Java Beginners
How to bookmark and preview last question in a java test engine  Am creating a test engine with java, how can i generate questions randomly, allow a user bookmark a question view previous question and review questions
How to bookmark and preview last question in a java test engine - Java Beginners
How to bookmark and preview last question in a java test engine  Am creating a test engine with java, how can i generate questions randomly, allow a user bookmark a question view previous question and review questions
clarify my question - Java Beginners
clarify my question  Dear Sirs/Expert, Thanks for writing back. Yes. I want a page to use id of parents to do the search for the match. So... the matching tutors to the parent. I was telling you that my degree
Regarding My 3rd Question in Java - Swing AWT
Regarding My 3rd Question in Java  sir in Netbeans By default JTable Columns will appear Horizontal like Title1 Title2 Title3 Title4 in below these our data will appear so my question that is there any method
ModuleNotFoundError: No module named 'advice'
ModuleNotFoundError: No module named 'advice'  Hi, My Python... 'advice' How to remove the ModuleNotFoundError: No module named 'advice'... to install padas library. You can install advice python with following command
ModuleNotFoundError: No module named 'advice'
ModuleNotFoundError: No module named 'advice'  Hi, My Python... 'advice' How to remove the ModuleNotFoundError: No module named 'advice'... to install padas library. You can install advice python with following command
Some additions for my previous question - Java Beginners
Some additions for my previous question  This is the question I... for the GUI. Could anyone please help?" So my other two questions are: 1... the user with a command line menu. The choices are p, f, q and n. In case
What are the types of Advice?
What are the types of Advice?   Hi, What are the types of Advice? Thanks
Question
Question   When there is an exception in my program how java runtime system handles
question
question  dear sir/madam my question is how to compare two text format in java..we are java beginners..so we need the complete source code for above mentioned question...we have to compare each and every word
question
question  Dear sir i had some typing mistake at previous question so its my humble request to let me know the steps to start the tomcat6 under the tomcat directory
ModuleNotFoundError: No module named 'tf-contextual-prediction-with-expert-advice'
-advice'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'tf-contextual-prediction-with-expert-advice...-prediction-with-expert-advice' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'tf-contextual-prediction-with-expert-advice'
-advice'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'tf-contextual-prediction-with-expert-advice...-prediction-with-expert-advice' error? Thanks   Hi, In your
Question
Question  Sir, which is more better and good to study in struts1 or struts2.compare these two and give me an advice to select of them.reply me as soon as possible.   Please visit the following links: http
question
question   sir plz tell me what should i give in title box. just i want java program for the question typed in this area
question
question   sir plz tell me what should i give in title box. just i want java program for the question typed in this area
A question
contains further 2 subfolders named "classes" and "lib" and a "web.xml" page. The "classes" folder contains further a subfolder "package1"."package1" further
Packages needed for JDBC in Linux
Packages needed for JDBC in Linux  Can anyone tell me the packages needed to run a program with JDBC in Red Hat 5
question
could get the last results only from resultset,please correct this how to set
question
;/tr> </table> this is my jsp page package servlet; import java.io.... Last Name:"); l4=new JLabel("Employee Address:"); l5=new JLabel...:"); l16=new JLabel("Employee First Name:"); l17=new JLabel("Employee Last Name
help Needed with requirements
help Needed with requirements  Following are my requirements : * Maintain a student database *Based on a student's test results ,reports should be generated so as to project details such as a students weakness in a particular
Question?
Question?  My question is how to: Add a menu bar to the program with a File menu. In the File menu, add a submenu (JMenuItem) called About. When the user clicks on the About menu item, display a JOptionPane message dialog
question
question  Gud morning sir, I have asked u some question regarding jsp in saturaday for that i didnot find any answere in which u send me the some of the links.U have asked me the specify some details. There is a entity name
question
question  Sir , i have a starting trouble to start my search engine project , please help me to start my project , please send me some relevant java codes
QUESTION
QUESTION  please atach java tutorial to my email   Hello Friend, Please visit the following link: Java Tutorial Thanks
Help needed in JSP
Help needed in JSP  Hi .. I want to Update the multiple values of database using checkboxes and want to set the session for selected checkboxes..? please answer if any one knows as soon as possible
Needed jsp codes
Needed jsp codes   jsp code for employee payroll.producing a payslip of every employees monthly calculating the gross pay of a particular employee considering the income tax and producing a report which can be printed out
question
question  i am using this code in my project response.sendRedirect("LoginForm1.jsp?msg=Username or Password is incorrect!"); but i wan't to hide this message from url.please help me
question
question  Sir, how to display web snippets for a perticular query for eg:web snippets for apple how to implement this concept in my java project please help me
question
question  i need to mark employees as half day absent who came after 10'o clock in my web project,so i need to know who are all late entry.if you have any idea using jsp and mysql please help me
question
to develop my java project
question
question  Sir, i am developing a video streaming PC server to j2me client system that the j2me player can playing video from PC server .if have any code for video streaming then send to my email address as soon as possible
question
/) is not available.** how tdo i solve this.please help me to run my project please give
question
question  i am using this code in my project response.sendRedirect("LoginForm1.jsp?msg=Username or Password is incorrect!"); but i wan't to hide this message from url.please help me. you gave me the response Hi Jamsiya
question
question  following is my code to sent mail but i couldn't work with eclipse ,that have some errors .need i any set up in eclipse or tell to what can i do to work code properly. <%@ page import="java.io." import="java.lang.
Needed java code
Needed java code  1.Java code for the time used to display your name, one character at a time, for 200,000 times . 2.Java code for the time used to display your name, one character at a time in reverse order, for 200,000 times
Spring AOP Around Advice
.style1 { background-color: #FFFFCC; } Spring AOP Around Advice Around Advice performs the custom behavior before and after method invocation... you need advice for both entry and exit then only use this advice
degree needed for data scientist
degree needed for data scientist  Hi, I am beginner in Data Science... needed for data scientist Try to provide me good examples or tutorials links so that I can learn the topic "degree needed for data scientist"
degree needed to be a data scientist
degree needed to be a data scientist  Hi, I am beginner in Data...: degree needed to be a data scientist Try to provide me good examples or tutorials links so that I can learn the topic "degree needed to be a data
What degree is needed for AI?
What degree is needed for AI?  Hi, I am beginner in Data Science... degree is needed for AI? Try to provide me good examples or tutorials links so that I can learn the topic "What degree is needed for AI?". Also tell me
A program solution needed
A program solution needed   I need a solve for this problem please ! a program that displays grade statistics. The program should read any number of grades (up to 100) and ends when the user enters -1, the program should reject

Ads