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



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

Have Programming Question? Ask it here!
 
 
 


Karen
Further advice needed on my last question
1 Answer(s)      4 years and a month 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
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
Question
Question   When there is an exception in my program how java runtime system handles
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
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
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
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
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
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
php show last query
php show last query  How to show the last updated record from the database in PHP? Is there any query that i need to write in the php script
help needed for a program - Java Beginners
help needed for a program   i am having trouble understanding on what to code, so can some 1 help me out here. thanks in advance. Part I Write, compile and execute a Java program that displays the following prompts
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
Transaction in last 3 months
Transaction in last 3 months  I have a project in which i have to calculate amount submitted through transactions in last three months. I have to check the date of all transactions in past 90 days and add the total amount
Mysql last day of month
Mysql last day of month       Mysql Last Day of Month is useful to provide you the last... an example from Mysql Last Day of Month. To understand the example we use
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
servlet redirect problem help needed
will move to the last location which is stored in string obj... out and also execute the last portion of the code...and giving error i thought... when the first re.forward(req, resp); executes...and what whappen when the last
servlet redirect problem help needed
will move to the last location which is stored in string obj... out and also execute the last portion of the code...and giving error i thought... when the first re.forward(req, resp); executes...and what whappen when the last
look up values help needed
2.35000000000000000000 so in my case, (212.5kgs) I need to return the value
PHP help needed - Development process
PHP help needed  This is my code that I am using for search engine, can any body answer how to cheange the code if I want limited and per page result display??? code Career Search result Yami says <?php
Mysql Last
Mysql Last       Mysql Last is used TO limit Mysql query result that fall in a specified range... results. The syntax to show the last records is pharsed as Limit X,Y. The X stands
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
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
could get the last results only from resultset,please correct this how to set
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
Advertisements
 

 

 

DMCA.com