Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet Further advice needed on my last question
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Karen
Further advice needed on my last question
1 Answer(s)      4 years and 5 months 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.

Advertisement
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
What are the types of Advice?
What are the types of Advice?   Hi, What are the types of Advice? Thanks
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
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
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
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   When there is an exception in my program how java runtime system handles
Spring AOP After Throws Advice
.style1 { background-color: #FFFFCC; } Throws Advice Example This advice is executed when a method throws an exception. To implement throws advice you need to implement ThrowsAdvice Interface of import
Spring AOP After Returning advice
Advice Example In this tutorial you will learn how to invoke method after advice This advice is executed when program exits the joinpoints...="advice">          <
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
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
Java help needed
as needed by the number of characters of the chosen word. 2. Add 4 buttons or menu
Code Help Needed
off last time. It will also systematiclly fill in the arrays. { System.out.println("Please enter student's last name, Enter end to quit
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
php remove last character
php remove last character  to remove the last character, i used the trim function which is not working
Needed modifications to ApplicationContext if extending this application
Needed modifications to ApplicationContext if extending this application   I followed the Developing Struts Hibernate and Spring Based Login... according to my requirement, If you can please give me an example
 

 

 

DMCA.com