[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Nina Savannah wrote: I would be ALL SMILES if you could give a running jsp code
Nina Savannah wrote:or should I paste the code that I already have even though its not working?
[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Nina Savannah wrote:I have done the configurations but I am now stuck at the end.
My system is located at $CATALINA_HOME/webapps/ROOT/publications
I have saved test.jsp in $CATALINA_HOME/webapps/ROOT/publications
Nina Savannah wrote:
I have saved publications.war in $CATALINA_HOME/webapps/
Nina Savannah wrote:
and I have edit the code as follows:
****TEST.JSP****
<html>
<head>
<title>publications</title>
</head>
<body>
<% out.print("HELLO!!!");
foo.publications tst = new foo.publications();
tst.init();
%>
<h2>Results</h2>
Foo <%= tst.getFoo() %>
Bar <%= tst.getBar() %>
</body>
</html>
****publications.war****
package foo;
import javax.naming.*;
import javax.sql.*;
import java.sql.*;
public class publications {
String foo = "Not Connected";
int bar = -1;
public void init() {
try{
Context ctx = new InitialContext();
if(ctx == null )
throw new Exception("Boom - No Context");
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/publications");
if (ds != null) {
Connection conn = ds.getConnection();
if(conn != null)
{
foo = "Got Connection "+conn.toString();
Statement stmt = conn.createStatement();
ResultSet rst =
stmt.executeQuery(
"select school_code, school_name, bar from out_school");
if(rst.next()) {
foo=rst.getString(2);
bar=rst.getInt(3);
}
conn.close();
}
}
}catch(Exception e) {
e.printStackTrace();
}
}
public String getFoo() { return foo; }
public int getBar() { return bar;}
}
Nina Savannah wrote:
I wasnt so sure of how to save a war file so I opened a new jsp page in macromedia then pasted the code gave at a .war extension when I was saving it.
Nina Savannah wrote:
When I run http://localhost:8080/publications/test.jsp i get the the following errors:-
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 7 in the jsp file: /publications/test.jsp
Generated servlet error:
foo.publications cannot be resolved or is not a type
An error occurred at line: 7 in the jsp file: /publications/test.jsp
Generated servlet error:
foo.publications cannot be resolved or is not a type
Now I dont know how to correct this.... :roll:
[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
SCJP, SCWCD.
|Asking Good Questions|
Sagar Rohankar wrote:
After all this clarification I think you need a simple JSP/Servlet tutorial which taught a step by step procedure to build and run web app. http://www.roseindia.net/jsp/ OR look at JSP/Servlet FAQ on this site.
Bauke Scholtz wrote:
Sagar Rohankar wrote:
After all this clarification I think you need a simple JSP/Servlet tutorial which taught a step by step procedure to build and run web app. http://www.roseindia.net/jsp/ OR look at JSP/Servlet FAQ on this site.
If you're new to Java EE, do certainly NOT use roseindia.net.
Read this: http://balusc.blogspot.com/2008/06/what-is-it-with-roseindia.html
[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Nina Savannah wrote:
Before I proceed I would like to clarify one thing. Once I have done the settings in web.xml and server.xml, is that all there is for Connection Pooling or am I supposed to write a jsp code that implements the Connection Pooling?
Nina Savannah wrote:
Also, what is the right way to save a war file? Do I need special software for this?
[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Swastik
passwords must contain 14 characters, a number, punctuation, a small bird, a bit of cheese and a tiny ad.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|