File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes browser returning error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "browser returning error" Watch "browser returning error" New topic
Author

browser returning error

Anand Shrivastava
Ranch Hand

Joined: Jul 22, 2007
Posts: 125
i have made the following jsp page
<jsp:directive.page import="java.sql.*" />
<jsp:scriptlet>
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbcracleci:@xe","hr","hr");
Statement stmnt = con.createStatement();
ResultSet rs=stmnt.executeQuery("select * from countries");
rs.first();
String country = rs.getString("COUNTRY_NAME");
statement.close();
connection.close();
}
catch (Exception E) {out.println(E.getmessage());}
</jsp:scriptlet>
<HTML>
<HEAD>
<TITLE>
</TITLE>
</HEAD>
<BODY>
</BODY>
BUT THE BROWSER from tomcat RETURNS THE FOLLOWING ERROR

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

An error occurred at line: 2 in the jsp file: /connection.jsp
statement cannot be resolved
1: <jsp:directive.page import="java.sql.*" />
2: <jsp:scriptlet>
3: try {
4: Class.forName("oracle.jdbc.driver.OracleDriver");
5: Connection con = DriverManager.getConnection("jdbcracleci:@xe","hr","hr");

KINDLY HELP.


Anand Shrivastava
SCJA
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61448
    
  67

Why are you using the JSP XML document format in your JSP?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Anand Shrivastava
Ranch Hand

Joined: Jul 22, 2007
Posts: 125
learnt it from [URL=http://www.ibm.com/developerworks/java/library/j-webdata/
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61448
    
  67

The JSP document format is not suitable for hand coding. It is primarily intended for the container to use as an intermediary representation of a page, or for when JSP pages are autogenerated from code where a DOM can be built and serialized.

I'd strongly suggest just using the "normal" JSP syntax. Trying to use the document sytnax will just yield a frustrating series of errors trying to get the very strict markup just right.
Anand Shrivastava
Ranch Hand

Joined: Jul 22, 2007
Posts: 125
tell me exactly how it should be done. I am very new to jsp and this is my first jsp.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61448
    
  67

You'll need to find a good book or tutorial on JSP. One that covers JSP 2.0.

You should probably also read this article to make sure you understand what JSP is fomr the start.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: browser returning error