CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Guest

    servlet Not Running

    Hi folks ,
    When I compile the servlet ,no error.
    But When I open it in the browser nothing coming and when I see the viewsource following error is coming.
    plese help
    san
    !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML><HEAD>
    <META content="text/html; charset=windows-1252" http-equiv=Content-Type></HEAD>
    <BODY></BODY></HTML>



    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;

    public class Demo1 extends HttpServlet
    {
    ResultSet rs;

    Statement stmt;
    Connection con;
    /*public void init(ServletConfig config) throws ServletException
    {
    super.init(config);


    }

    public void destroy()
    {

    super.destroy();
    }*/

    public void doGet(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException
    {
    resp.setContentType("text/html");
    PrintWriter out = new PrintWriter(resp.getOutputStream());

    try{

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection("jdbcdbc:PERDET");
    stmt = con.createStatement();

    rs = stmt.executeQuery("select * from EMPLOYEE");

    out.println("<HTML>");
    out.println("<HEAD><TITLE>Employee details</TITLE></HEAD>");
    out.println("<BODY>");
    out.println("asdfasdf");
    //out.close();
    out.println("<UL>");

    while(rs.next())
    {

    out.println("<LI>" + rs.getString("NAME") + " "+rs.getString("SALARY")+ " " +rs.getString("DOB"));
    }
    out.println("</UL>");

    out.println("</BODY>");
    out.println("</HTML>");
    out.close();
    } catch(Exception e) {e.printStackTrace();}

    finally
    {
    try
    {
    if (con != null) con.close();

    }catch (Exception e) {e.printStackTrace();}

    }
    }


    }



  2. #2
    Join Date
    May 1999
    Location
    USA
    Posts
    27

    Re: servlet Not Running

    I am not sure abt the error. How did you make out the error from the source? Is it wrong HTML? Or different one from what you expected?
    Please see what the "java console" of your browser says (if at all it does :-) ) and post that.
    Thanks,
    Amaresh


  3. #3
    Guest

    Re: servlet Not Running

    hi amaresh,

    When I compile the servlets ,it's successfully built.,When I open the class file ,Iam not getting anything.
    Then I right clicked the mouse to view the source in that page.Iam getting that info(that is the source generated by the servlet).
    please give me the solution and what is the problem in the servlet.
    regs
    san


  4. #4
    Join Date
    May 1999
    Location
    USA
    Posts
    27

    Re: servlet Not Running

    I understand that there are no compilation errors. But inorder to find the run time error, I suggest that you open
    the "java console" in your browser and post whatever you find there. Open the "java console" in your browser,
    and then access the servlet. Then you will see lot of text(exceptions etc) getting diplayed in the java console window.
    Please post that here. That will help me to guess what exactly is going on ..
    Thanks,
    Amaresh


  5. #5
    Guest

    Re: servlet Not Running

    Some small points. My guess is u r using Netscape browser. Do the following
    take the result set outputs seperately in variables and then print the list item.
    Secondly, try closing all tags. <li> with </li> etc. Try out and see. This might work.


  6. #6
    Join Date
    Oct 1999
    Posts
    4

    Re: servlet Not Running

    Reposting this mail again

    Some minor points. I guess u r using Netscape browser. Try doing some small changes.
    First, take the data from all the columns into variables and then add to the list. Check for nulls
    Using rs.wasNull() after each getString and then substitute them with "".
    Secondly, close all tags <li> with </li>. Try this out. It might work.


  7. #7
    Join Date
    Aug 1999
    Location
    newjersy usa
    Posts
    4

    Re: servlet Not Running

    Hi amaresh,
    I could not find "java console" in the browser .Iam using both IE &netscape.
    Please reply for this.
    regs
    san


  8. #8
    Join Date
    May 1999
    Location
    USA
    Posts
    27

    Re: servlet Not Running

    In Netscape, go to the menuitem "Communicator - Tools - Java Console"
    In IE, choose the menu "View - Java Console".
    In IE, if you don't see the menu item "Java Console" under the menu "View", it means you have not enabled that option. To enable it,
    choose "View - Internet Options". You will see a tabbed dialog on the screen. Now click on the tab "Advanced". If you keep scrolling,
    you will see a check box "Java Console Enabled".Check that box and restart your IE browser. Now you will see the "Java Console" menu
    item under "View" menu in IE.
    Thanks,
    Amaresh


  9. #9
    Join Date
    Aug 1999
    Location
    newjersy usa
    Posts
    4

    Re: servlet Not Running

    hi amaresh,
    I solved the problem.I didn't closed the o/p stream.
    but this is the info that I got it from "java console".Thanks a lot for your help.
    thanks and regs
    shan

    _____________
    Netscape Communications Corporation -- Java 1.1.5
    Type '?' for options.
    Symantec Java! ByteCode Compiler Version 210.065
    Copyright (C) 1996-97 Symantec Corporation



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured