Solved

Adding comment to jsp page

Posted on 2012-03-30
9
697 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
ID: 37789897
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
ID: 37789898
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
ID: 37789899
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
ID: 37789907
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 23

Assisted Solution

by:Siva Prasanna Kumar
Siva Prasanna Kumar earned 150 total points
ID: 37789908
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
ID: 37789979
1) is this homework?
2) be aware of w3schools shortcomings: http://w3fools.com/
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 37794995
>>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
ID: 37814924
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
ID: 37814926
Thank you very much.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In the hope of saving someone else's sanity... About a year ago we bought a Cisco 1921 router with two ADSL/VDSL EHWIC cards to load balance local network traffic over the two broadband lines we have, but we couldn't get the routing to work consi…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

895 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

11 Experts available now in Live!

Get 1:1 Help Now