Solved

Adding comment to jsp page

Posted on 2012-03-30
9
696 Views
Last Modified: 2012-04-05
Below I have a short jsp code:

<%@ page info="if Example JSP" %>
<html>
    <head>
        <title>Chapter 5 Examples</title>
    </head>
    <body>
        <b>IF Statement Example ( Response ) <br /></b>
        <br />
                  
        <%
            int quantity = Integer.parseInt(request.getParameter("quantity"));
            if (quantity > 0) {
                out.println("Thank-you for your order!!");
            } else {
                out.println("Sorry. please enter a possitive quantity");
            }
        %>                        
    </body>
</html>

Q1: What is the first line for?     <%@ page info="if Example JSP" %>
Q2. Could you add some comments to this code? I want to learn about your syntax and styke.
Q3: Is it a good idea to use XHTM not HTML?
Q4: Is the decelaration line shown below necessary to be included?
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

Thank you.
0
Comment
Question by:Mike Eghtebas
9 Comments
 
LVL 47

Accepted Solution

by:
for_yan earned 350 total points
Comment Utility
This is about comments in JSP
read here for details and examples:
http://www.roseindia.net/jsp/simple-jsp-example/comment.shtml

1) Hidden comment: This comment will not appear in the output.

<%-- Hidden comment --%>

2) Output comment: This type of comment will appear in the output.

<!-- Output comment>

If we have to pass the comment inside the directive then there we use a single line comment i.e. //
0
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 350 total points
Comment Utility
read here about attributes of the JSP page:
http://www.roseindia.net/jsp/PageDir_Example.shtml

info is one of the attributes - you can read about it among other probably more useful attributes here:

info: This attribute simply sets the information of the JSP page which is retrieved later by using Servlet.getServletInfo() method. The value of the attribute will be a text string.
0
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 350 total points
Comment Utility
read here about XHTML and XTML
http://www.webstandards.org/learn/articles/askw3c/oct2003/

second part of the page - specificllay addresses the advantages of XHTML vs HTML
0
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 350 total points
Comment Utility
read here
http://www.w3schools.com/tags/tag_doctype.asp
about DOCTYPE


<caption>
<center>
<cite>
<code>
<col>
<colgroup>
<dd>
<del>
<dfn>
<dir>
<div>
<dl>
<dt>
<em>
<fieldset>
<font>
<form>
<frame>
<frameset>
<head>
<h1> - <h6>
<hr>
<html>
<i>
<iframe>
<img>
<input>
<ins>
<kbd>
<label>
<legend>
<li>
<link>
<map>
<menu>
<meta>
<noframes>
<noscript>
<object>
<ol>
<optgroup>
<option>
<p>
<param>
<pre>
<q>
<s>
<samp>
<script>
<select>
<small>
<span>
<strike>
<strong>
<style>
<sub>
<sup>
<table>
<tbody>
<td>
<textarea>
<tfoot>
<th>
<thead>
<title>
<tr>
<tt>
<u>
<ul>
<var>
HTML <!DOCTYPE> Declaration
Example

An HTML document with a doctype of XHTML 1.0 Transitional:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Title of the document</title>
</head>

<body>
The content of the document......
</body>

</html>

Try it yourself »
Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The <!DOCTYPE> declaration is supported in all major browsers.
Definition and Usage

The <!DOCTYPE> declaration must be the very first thing in your HTML document, before the <html> tag.

The <!DOCTYPE> declaration is not an HTML tag; it is an instruction to the web browser about what version of HTML the page is written in.

The <!DOCTYPE> declaration refers to a Document Type Definition (DTD). The DTD specifies the rules for the markup language, so that the browsers render the content correctly.

Tip: Always add the <!DOCTYPE> declaration to your HTML documents, so that the browser knows what type of document to expect.
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 23

Assisted Solution

by:Siva Prasanna Kumar
Siva Prasanna Kumar earned 150 total points
Comment Utility
Q1: What is the first line for?     <%@ page info="if Example JSP" %>

The "info" attribute simply sets the information of the JSP page which is retrieved later by using Servlet.getServletInfo() method. The value of the attribute will be a text string. It's as good as servelet info in simple terms so additional significance.

Q2. Could you add some comments to this code? I want to learn about your syntax and styke.

<%@ page info="if Example JSP" %>
<html>
    <head>
<!-- This is the title of HTML Page which is displayed on the window/tab of web browser. -->
        <title>Chapter 5 Examples</title>
    </head>
    <body>
        <b>IF Statement Example ( Response ) <br /></b>
        <br />
                  
        <%
//Trying to get the int value of parameter passed with in the request scope.
            int quantity = Integer.parseInt(request.getParameter("quantity"));
            if (quantity > 0) {
//if some value of quantity found and greater than zero print this response.
                out.println("Thank-you for your order!!");
            } else {
//if no request parameter quantity found or quantity =0 print this response.
                out.println("Sorry. please enter a possitive quantity");
            }
        %>                        
    </body>
</html>

Open in new window


Q3: Is it a good idea to use XHTM not HTML?
XHTML is the safest, HTML tags may or may not have ending tags and hence different browsers may render them differently.

Q4: Is the decelaration line shown below necessary to be included?
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

Best explained here: http://www.w3schools.com/tags/tag_doctype.asp
0
 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
1) is this homework?
2) be aware of w3schools shortcomings: http://w3fools.com/
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
Comment Utility
>>Q1: What is the first line for?     <%@ page info="if Example JSP" %>
As  shivaspk the information get from Servlet.getServletInfo() method. This is very useful where a huge number of server programs are running on a server and you need to know about a particular servlet or JSP. otherwise no need .

other question are alreday gave gd explaintion by experts
0
 
LVL 33

Author Comment

by:Mike Eghtebas
Comment Utility
mplungjan,

No this is not homework. This is work related (small portion of what I do). I am lucky to have this chance.
0
 
LVL 33

Author Closing Comment

by:Mike Eghtebas
Comment Utility
Thank you very much.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This article explains in simple steps how to renew expiring Exchange Server Internal Transport Certificate.
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now