tags:

views:

60

answers:

3

Hey folks, ok so this is my problem, I need to display HTML code in a jsp, which wouldn't be a problem, except a requirement for this project is that we place all the code in a public class file and have seperate methods for each chunk(header, sidebar footer, etc). Now here's where i'm confused:

"Your method should take the PrintWriter as a parameter to print out each line of HTML, and should have a return type of void"

What does that mean? How do I pass the PrintWriter into a method? Does this make sense to anyone?

+2  A: 

Your question is far from clear, but it sounds like you need to write code like this:

public void writeHeader(PrintWriter out)
{
    ...
}

public void writeSidebar(PrintWriter out)
{
    ...
}

public void writeFooter(PrintWriter out)
{
    ...
}
Jon Skeet
+2  A: 

It means that your method (that you will have to name yourself) will have one argument of type PrintWriter. In your method you should then call that variable's print method.

I am deliberately vague here, because you should do some of your homework yourself :)

Peter Jaric
Oh no! Jon Skeet answered the same question as me! I am doomed :)
Peter Jaric
But he used C# style braces so I'm upvoting yours :P
OscarRyz
Me too :( I'm doomed as well!
Vivin Paliath
+1  A: 

"Your method should take the PrintWriter as a parameter to print out each line of HTML, and should have a return type of void"

That's pretty clear to me:

/* return type void -->*/ void yourMethodNameHere( PrintWriter parameter ) { /*<--  Pw as parameter*/
                          }

What does that mean?

Exactly that

How do I pass the PrintWriter into a method?

Ah, this is the interesting part. I'll give you a hint, check it out: http://www.google.com/search?&amp;q=jsp+predefined+variables

Does this make sense to anyone?

Pretty much

OscarRyz