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
Solved

Adding comment to jsp page

Posted on 2012-03-30
9
700 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

 
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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
xjc and jaxb 2 94
tomcat users xml 7 127
java.util.concurrent.locks in java 3 199
Unhandled exception type Exception 18 42
Learn how to PXE Boot both BIOS & UEFI machines with DHCP Policies and Custom Vendor Classes
There's a lot of hype surrounding blockchain technology. Here's how it works and some of the novel ways it' s now being used - including for data protection.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

809 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