Source code not visible in browser

Discussion in 'Java' started by Mikey, Jan 25, 2006.

  1. Mikey

    Mikey Guest

    I am new to servlets and I have a question about viewing the response
    source code on my browser. I'm not sure if this is a problem with my
    response headers or what.

    My servlet creates a response and sends it back to the browser where it
    is displayed correctly. However, when I attempt to view the source code
    in the browser (both IE and Netscape) the display is blank.

    The servlet code is:

    res.setContentType("text/html");
    PrintWriter out = res.getWriter();
    out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
    "Transitional//EN\">\n" +
    "<HTML>\n" +
    "<HEAD><TITLE>Submit Experiment
    Results</TITLE></HEAD>\n" +
    "<BODY>\n" +
    "<br><br><br><br><center>\n" +
    "<H2>Experimental Results Recorded</H2>\n" +
    "<table border=\"1\" width=\"500\" cellpadding=\"10\"
    cellspacing=\"0\"><tr><td>" +

    "<H3>Your submitted data have been recorded. You can
    either proceed to having your results gradded or click the \"Back\"
    button on your browser to again review your data.</H3>\n" +
    "</td></tr>" +

    "<tr><td>" +
    "<H3>After you have clicked the \"Grade Results\"
    button, an email with your score will be sent to both you and your
    instructor.</H3>\n" +

    "</td></tr></table>" +

    "</center></BODY></HTML>");

    As I develop the servlet code I would like to be able to view the
    received html file on the browser for debugging purposes.

    Any help would be appreciated.

    Thanks.
    Mikey, Jan 25, 2006
    #1
    1. Advertising

  2. Mikey

    Joe Attardi Guest

    Mikey wrote:
    > My servlet creates a response and sends it back to the browser where it
    > is displayed correctly. However, when I attempt to view the source code
    > in the browser (both IE and Netscape) the display is blank.


    Hey Mikey,

    Not sure about this problem, but you would be better off using a JSP to
    display your results in the browser. It's much easier to read the code,
    and is generally just a good practice.
    Joe Attardi, Jan 25, 2006
    #2
    1. Advertising

  3. Mikey

    zero Guest

    "Mikey" <> wrote in news:1138205075.563497.44970
    @g44g2000cwa.googlegroups.com:

    > My servlet creates a response and sends it back to the browser where it
    > is displayed correctly. However, when I attempt to view the source code
    > in the browser (both IE and Netscape) the display is blank.


    If the browser displays the page correctly, it means it's receiving the
    source code correctly. You should be able to use the browser's "view page
    source" or similar to see the html source.
    zero, Jan 25, 2006
    #3
  4. Mikey

    Oliver Wong Guest

    "zero" <> wrote in message
    news:Xns9756C29EA897Ezerothishi@195.130.132.70...
    > "Mikey" <> wrote in news:1138205075.563497.44970
    > @g44g2000cwa.googlegroups.com:
    >
    >> My servlet creates a response and sends it back to the browser where it
    >> is displayed correctly. However, when I attempt to view the source code
    >> in the browser (both IE and Netscape) the display is blank.

    >
    > If the browser displays the page correctly, it means it's receiving the
    > source code correctly. You should be able to use the browser's "view page
    > source" or similar to see the html source.


    Zero is correct. You may need to scroll around (i.e. horizontally and/or
    vertically) to get visible characters (as opposed to whitespace) in the
    source viewing window.

    - Oliver
    Oliver Wong, Jan 25, 2006
    #4
  5. Mikey

    Roedy Green Guest

    On Wed, 25 Jan 2006 18:07:54 GMT, zero <> wrote, quoted or
    indirectly quoted someone who said :

    >If the browser displays the page correctly, it means it's receiving the
    >source code correctly. You should be able to use the browser's "view page
    >source" or similar to see the html source.


    An HTML validator will help you ferret out errors your eye overlooks
    in the generated HTML.

    See http://mindprod.com/jgloss/htmlvalidator.html
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
    Roedy Green, Jan 25, 2006
    #5
  6. In article <>, Mikey
    took the hamburger, threw it on the grill, and I said "Oh wow"...

    > I am new to servlets and I have a question about viewing the response
    > source code on my browser. I'm not sure if this is a problem with my
    > response headers or what.
    >
    > My servlet creates a response and sends it back to the browser where it
    > is displayed correctly. However, when I attempt to view the source code
    > in the browser (both IE and Netscape) the display is blank.
    >
    > The servlet code is:
    >
    > res.setContentType("text/html");
    > PrintWriter out = res.getWriter();
    > out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
    > "Transitional//EN\">\n" +
    > "<HTML>\n" +
    > "<HEAD><TITLE>Submit Experiment
    > Results</TITLE></HEAD>\n" +
    > "<BODY>\n" +
    > "<br><br><br><br><center>\n" +
    > "<H2>Experimental Results Recorded</H2>\n" +
    > "<table border=\"1\" width=\"500\" cellpadding=\"10\"
    > cellspacing=\"0\"><tr><td>" +
    >
    > "<H3>Your submitted data have been recorded. You can
    > either proceed to having your results gradded or click the \"Back\"
    > button on your browser to again review your data.</H3>\n" +
    > "</td></tr>" +
    >
    > "<tr><td>" +
    > "<H3>After you have clicked the \"Grade Results\"
    > button, an email with your score will be sent to both you and your
    > instructor.</H3>\n" +
    >
    > "</td></tr></table>" +
    >
    > "</center></BODY></HTML>");
    >
    > As I develop the servlet code I would like to be able to view the
    > received html file on the browser for debugging purposes.
    >
    > Any help would be appreciated.
    >
    > Thanks.


    You won't see the source code, just the generated code for the page.

    --
    Noodles Jefferson
    mhm31x9 Smeeter#29 WSD#30
    sTaRShInE_mOOnBeAm aT HoTmAil dOt CoM

    NP: "Icicle" (Tour Rehearsal) -- Tori Amos

    "Our earth is degenerate in these latter days, bribery and corruption
    are common, children no longer obey their parents and the end of the
    world is evidently approaching."
    --Assyrian clay tablet 2800 B.C.
    Noodles Jefferson, Jan 26, 2006
    #6
  7. Mikey

    Mikey Guest

    I agree. The page displays fine but the received html does not display
    completely, or at all, when I view source code.

    Thanks for all your comments.
    Mikey, Jan 26, 2006
    #7
  8. Mikey

    Mikey Guest

    Thanks for the reply Joe. Do you have a reference where I could get
    some details on your suggestion.

    Thanks again.
    Mikey, Jan 26, 2006
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tshad

    button visible/not visible

    tshad, Oct 26, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    4,444
    Brian Hoops
    Oct 28, 2004
  2. tshad

    Sections visible and not visible

    tshad, Jan 31, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    2,060
    tshad
    Jan 31, 2005
  3. Patrick Olurotimi Ige
    Replies:
    7
    Views:
    5,965
    Patrick Olurotimi Ige
    Jun 15, 2005
  4. WRH
    Replies:
    9
    Views:
    1,171
    Kevin Spencer
    Nov 8, 2005
  5. Jurjen de Groot
    Replies:
    0
    Views:
    302
    Jurjen de Groot
    May 19, 2008
Loading...

Share This Page