Source code not visible in browser

M

Mikey

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.
 
J

Joe Attardi

Mikey said:
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.
 
Z

zero

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.
 
O

Oliver Wong

zero 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.

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
 
N

Noodles Jefferson

Mikey said:
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.
 
M

Mikey

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.
 
M

Mikey

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

Thanks again.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,149
Members
46,695
Latest member
StanleyDri

Latest Threads

Top