Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

browser returning error

 
Anand Shrivastava
Ranch Hand
Posts: 125
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you using the JSP XML document format in your JSP?
 
Anand Shrivastava
Ranch Hand
Posts: 125
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
learnt it from [URL=http://www.ibm.com/developerworks/java/library/j-webdata/
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 125
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic