Solved

Adding comment to jsp page

Posted on 2012-03-30
9
702 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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 34

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 34

Author Closing Comment

by:Mike Eghtebas
ID: 37814926
Thank you very much.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Apache server configuration 7 92
iterator example remove 8 75
Getting NoSuchMethodError on accessing a spring mvc project 3 173
batch vs regular insert in spring DAO 2 25
Always backup Domain, SYSVOL etc.using processes according to Microsoft Best Practices. This is meant as a disaster recovery process for small environments that did not implement backup processes and did not run a secondary domain controller that ne…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

730 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