13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

19.3 How to Write a JSP <str<strong>on</strong>g>Applicati<strong>on</strong></str<strong>on</strong>g>429...We’ve put a comment just prior to the tag. What will happen is thatthe comment will be part of the generated HTML, and since this is a loop, thecomment, just like the and other tags, will be repeated for each iterati<strong>on</strong>of the loop. Now we’re not saying this is undesirable—in fact it makes the resultantHTML more readable. But be aware that these comments will be visibleto the end user. Be careful in what you say in them. The additi<strong>on</strong>al transmissi<strong>on</strong>time required for these few extra bytes is probably imperceptible, unless yourcomments are large and repeated many times.19.3.2 Declarati<strong>on</strong>The other place that code can be placed is outside the doGet() and doPost().It is still inside the class definiti<strong>on</strong> for the servlet class that gets generated fromthe JSP, but it is not inside any method. Such code is delimited like this:The exclamati<strong>on</strong> mark makes all the difference. Since it’s outside anymethod, such code typically includes things like variable declarati<strong>on</strong>s andcomplete method declarati<strong>on</strong>s. For example:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!