Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML

Tutorial Categories: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML

Fresher Job


 

Search Host

Monthly Fee($)
Disk Space (MB)
Register With us for Newsletter!
Visit Forum! Post Questions!
Jobs At RoseIndia.net!

Have tutorials?
Add your tutorial to our Java Resource and get tons of hits.

We offer free hosting for your tutorials. and exposure for thousands of readers. drop a mail
roseindia_net@yahoo.com
 
   

Tutorials

Java Server Pages

JAXB

Java Beans

JDBC

MySQL

Java Servlets

Struts

Bioinformatics

Java Code Examples

Interview Questions

 
Join For Newsletter

Powered by groups.yahoo.com
Visit Group! Post Questions!

Web Promotion

Web Submission

Submit Sites

Manual Submission?

Web Promotion Guide

Hosting Companies

Web Hosting Guide

Web Hosting

Linux

Beginner Guide to Linux Server

Frameworks

Persistence Framework

Web Frameworks

Free EAI Tools

Web Servers

Aspect Oriented Programming

Free Proxy Servers

Softwares

Adware & Spyware Remover

Open Source Softwares

jsp
Expert:keerthi
<%@ page import = "java.sql.*;" errorPage = "Error.jsp" %>


<%!
Connection con;
Statement st;
ResultSet rs;
ResultSetMetaData rsmd;
boolean flag = false;
%>

<html>
<body bgcolor = "abcdef">
<center>
<br><br><br>
<table border = 2>
<tr>


<%

String origin = request.getParameter("src");
String dest = request.getParameter("dest");

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("driver is loaded........");
con = DriverManager.getConnection("jdbc:odbc:msdsn");
System.out.println("got the con object ");
st = con.createStatement();
System.out.println("got the st object ");
rs = st.executeQuery("select * from FlightDetails where Source="+src+ "and Destination="+dest);
System.out.println("got the rs object");

rsmd = rs.getMetaData();
System.out.println("got the rsmd object");
int cnt = rsmd.getColumnCount();
System.out.println("after the cnt " + cnt);

for(int i=1;i<=cnt;i++)
{
%>
<td bgcolor = "##ffccccc"> <%= rsmd.getColumnName(i) %> </td>
<%
}
%>
</tr>


<%
while(rs.next())
{
%>
<tr>
<%
for(int i=1;i<=cnt;i++)
{
%>
<td> <%= rs.getString(i)%></td>

<%
}
%>
</tr>
<%
}

%>

result:
HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 20 in the jsp file: /Flightdetails.jsp

Generated servlet error:
[javac] Compiling 1 source file

C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\Airlines-Project\org\apache\jsp\Flightdetails_jsp.java:69: cannot find symbol
symbol : variable src
location: class org.apache.jsp.Flightdetails_jsp
rs = st.executeQuery("select * from FlightDetails where Source="+src+ "and Destination="+dest);
^
1 error


org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:127)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:418)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:461)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:442)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:552)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


note The full stack trace of the root cause is available in the Tomcat logs.


--------------------------------------------------------------------------------

Apache Tomcat/5.0.14
Answers
Hi keerthi,

U r using wrong variables in query expression.

U have to use "origin" not src in query expression as src is only request parameter but not local variable. Thats y it is telling "undefined symbol:src". Please change it.


Another thing is,

origin & dest are strings here. Ur syntax of query expression is wrong. Please change it as follows:

"select * from FlightDetails where Source='"+origin+"' and Destination='"+dest+"'"

If U have to use them as integers in the query, first convert them into integers and use them as follows:

"select * from FlightDetails where Source="+origin+" and Destination="+dest"

I think it will work fine.

Regards,
Sreenivas

More Questions
Post Answers
 
Ask Question Facing Programming Problem?
Useful Links
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification

Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2007. All rights reserved.