Hi Pradeep,
Still it is not working,do you have any other idea why it is not working after
changing as per your suggestion in the code .
Waiting any other idea or suggestion.....
Thanks
krishna
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
/**
* This is a simple example of an HTTP Servlet. It responds to the GET
* and HEAD methods of the HTTP protocol.
*/
public class Hello extends HttpServlet
{
/**
* Handle the GET and HEAD methods by building a simple web page.
* HEAD is just like GET, except that the server returns only the
* headers (including content length) not the body we write.
*/
public void doGet (HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
PrintWriter out;
String title = "Example Apache JServ Servlet";
// set content type and other response header fields first
response.setContentType("text/html");
try{
// then write the data of the response
out = response.getWriter();
out.println("<HTML><HEAD><TITLE>");
out.println(title);
out.println("</TITLE></HEAD><BODY bgcolor=\"#FFFFFF\">");
out.println("<H1>" + title + "</H1>");
out.println("<H2> Congratulations! ApacheJServ 1.1 is
working!<br>");
// Load the Oracle JDBC driver
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
//Connect to the Database
Connection con =
DriverManager.getConnection("jdbc:odbc:local123","scott","tiger");
//Driver drv=DriverManager.getDriver("jdbc:odbc:local123");
//Create a Statement
Statement stmt = con.createStatement();
//Query
ResultSet rset = stmt.executeQuery("select EMPNAME from EMP1");
// Iterate through the result and print the employee names
while(rset.next())
out.println(rset.getString("EMPNAME"));
}
catch( SQLException exc){
System.out.println(exc);
}
catch(IOException exe){
System.out.println(exe);
}
finally{
System.out.println("</BODY></HTML>");
System.out.close();
}
}
}
pradeep wrote:
> Hi
>
> put this piece of code
> > out.println("</BODY></HTML>");
> > out.close();
>
> outside(if possible in finally block / at the end of the program ) the
>
> >while (rs.next())
>
> loop statement.....
>
> HTH
>
> -pradeep
>
> -
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html