Home arrow Java & J2EE arrow Page 3 - Developing JavaServer Pages

Imitating HTML - Java

In this excerpt from chapter 4 of Joel Murach's Java Servlets and JSP, you'll learn how to develop a web application that consists of HTML pages and JavaServer Pages (JSPs). As you will see, JSPs work fine as long as the amount of processing that's required for each page is limited. When you complete this chapter, you should be able to use JSPs to develop simple web applications of your own.

TABLE OF CONTENTS:
  1. Developing JavaServer Pages
  2. The Code for the HTML Page that Calls the JSP
  3. Imitating HTML
  4. How to Create a JSP
  5. How to Use the Methods of the Request Object
  6. Retrieving Multiple Values
  7. How to Request a JSP
  8. Using Get and Post Methods
  9. Using the Post Method
  10. Managing Java Classes
  11. Class Location
By: Joel Murach
Rating: starstarstarstarstar / 65
May 12, 2004

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Description

Although a JSP looks much like an HTML page, a JSP contains embedded Java code. To code a scriptlet that contains one or more Java statements, you use the <% and %> tags. To display any expression that can be converted to a string, you use the <%= and %> tags.

When you code a JSP, you can use the implicit request object. This object is named request. You can use the getParameter method of the request object to get the values of the parameters that are passed to the JSP.

When you code a JSP, you can use the methods of the request object in your scriptlets or expressions. Since you don't have to explicitly create this object when you code JSPs, this object is sometimes referred to as the implicit request object. The scriptlet in this figure contains three statements that use the getParameter method of the request object. Each of these statements returns the value of the parameter that is passed to the JSP from the HTML page. Here, the argument for each getParameter method is the name of the textbox on the HTML page.

Once the scriptlet is executed, the values for the three parameters are available as variables to the rest of the page. Then, the three expressions can display these variables. Since these expressions are coded within the HTML tags for a table, the browser will display these expressions within a table.

After the table, the JSP contains some HTML that defines a form. This form contains only one control, a submit button named Return. When it is clicked, it takes the user back to the first page of the application. If you have any trouble visualizing how this button or the rest of the page will look when displayed by a browser, please refer back to Figure 1.

As you read this book, remember that it assumes that you already know the basics of Java programming. If you have any trouble understanding the Java code in this chapter, you may need a refresher course on Java coding. To quickly review the basics of Java coding, we recommend that you use Murach's Beginning Java 2 because it contains all the Java skills that you'll need for working with this book. 

Remember: this is from chapter four of Joel Murach's Java Servlets and JSP (Mike Murach & Associates, ISBN 1890774189, 2003). Grab a copy at your favorite book store today!

 Buy this book now.



 
 
>>> More Java & J2EE Articles          >>> More By Joel Murach
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

JAVA & J2EE ARTICLES

- More Java Bugs Lead to More Attacks
- Oracle's Java One Brings News, Surprises
- Oracle Patches Java Runtime Environment
- Apple Syncs Java Update with Oracle
- Spring 3.1 Java Development Framework Compat...
- Jelastic Java PaaS Availability and Pricing ...
- NetBeans 7.1 Released, Supports JavaFX 2
- SolarWinds Releases Newest Version of Java M...
- Free Monitoring Tool for Java Apps on Heroku
- Heroku Adds JCloud Platform Support, Java 7 ...
- Java SE 8 Speculation in Full Swing
- Java SE 7 Now Available
- New JVM Language and Java Reporting Tool
- Java 7 Release Update and New Eclipse Toolkit
- The Best Java Netbeans IDE Plugins

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: