Hey!
>System.out.println()s instead of using PrintWriter's out.println()s to show
>anything that I want on the browser?
If I understand your question, remember the servlet runs on the server box.
You can't get to the client's console. You can only get to the client's browser.
I think what you want to do is show process status while servlet is running.
You can do this but you need to implement a redirect methodology.
Please check the archive. Archives:
http://archives.java.sun.com/archives/servlet-interest.html
The redirect subject has been discussed many
times in the past. You should be able to glean information.
Sans adieu,
Danny Rubis
Andreas wrote:
> Hi to everybody,
>
> I have a servlet that connects to an Access DB and all it does it retrieves
> two columns of data from a table and displays it in HTML. What I want to d
> ois to use System.out.println()s in order to show on the console that
> servlet is activated, the right is received etc.. How exactly do I use
> System.out.println()s instead of using PrintWriter's out.println()s to show
> anything that I want on the browser? Basically where do I put
> theSystem.out.println()s in my code? Here is my simple example:
>
> import java.io.*;
> import java.sql.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
>
> public class SimpleLoginServlet extends HttpServlet {
>
> public void doGet(HttpServletRequest req, HttpServletResponse res)
> throws ServletException, IOException {
>
> Connection con = null;
>
> Statement stmt = null;
>
> ResultSet rs = null;
>
> res.setContentType("text/html");
>
> PrintWriter out = res.getWriter();
>
> try {
>
> //Load the MS Access driver
> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
>
> //Get a connection to the database
> con = DriverManager.getConnection("jdbc:odbc:RoomBookDB", "andreas",
> "stellatos");
>
> //Create a statement object
> stmt = con.createStatement();
>
> //Execute SQL query and get a result set
> rs = stmt.executeQuery("SELECT USERNAME, PASSWORD FROM LECTURERS");
>
> // Display the result set as a list
> out.println("<HTML><HEAD><TITLE>Confidential List</TITLE><HEAD>");
> out.println("<BODY>");
> out.println("<UL>");
> while(rs.next()) {
> out.println("<LI>" + rs.getString("username") + " " +
> rs.getString("password"));
> }
> out.println("</UL>");
> out.println("</BODY></HTML>");
> }
> catch(ClassNotFoundException e) {
> out.println("Couldn't load the database driver: " + e.getMessage());
> }
> catch(SQLException e) {
> out.println("SQL Exception caught: " + e.getMessage());
> }
> finally {
> //Always close the database connection
> try {
> if (con != null) con.close();
> }
> catch (SQLException ignored) { }
> }
> }
> }
>
> Thanks for the help,
>
> Andreas
>
> ___________________________________________________________________________
> 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
___________________________________________________________________________
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