Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Adding comment to jsp page

Posted on 2012-03-30
9
Medium Priority
?
707 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 1400 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 1400 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 1400 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 1400 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 600 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Working from home is a dream for many people who aren’t happy about getting up early, going to the office, and spending long hours at work. There are lots of benefits of remote work for employees.
If something goes wrong with Exchange, your IT resources are in trouble.All Exchange server migration processes are not designed to be identical and though migrating email from on-premises Exchange mailbox to Cloud’s Office 365 is relatively simple…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

636 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