Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

Further advice needed on my last question

Ads

 
 

Share on Google+Share on Google+

Karen
Further advice needed on my last question
1 Answer(s)      7 years ago
Posted in : JSP-Servlet
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.
Ads
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

Ads









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
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
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
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
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
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
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   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
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
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
php remove last character
php remove last character  to remove the last character, i used the trim function which is not working
Last modified date of a folder
Last modified date of a folder  How to get the last modified date of a folder specified by a link in html
Last modified time of a webpage
Last modified time of a webpage  how can we get the last modified time of a webpage using java