Likes

WCD-LAB @HOME 1-Ans 3

Section : Introduction to Java Server Pages (1 of 1)1. Create an HTML form and a simple JSP that handles input from that form.



the servlet system described in the previous modules provides asimple
and effective way to use java to respond to HTTP request.when combined
with the powerful and varied library APIS available to a java program,
HTmL page that implement the designs are frequently created using"
what you see is what you get"(WYSIWYG)Graphical user interface(GUI)based design tools.
such design tools works on HTML,not HTMLembedded in java programe code.

because of thethis,pure servlet approach beacomes unmanageable-often catastrophically-
when maintenance is required on the web page.having to re-types all the HTML code back
into out.print(.....)statements would be a very time consuming and error prone process.

while a servlet isajava source file containing embeddedd HTML,A JSP might be consigered to be an HTML file
with java embedded in it,code2-1below shows  an example of the very simple jsp.

1.<%--
2 simple hello world jsp example
3---%>
4
5<%@page content type="text/html"pageEncoding="UTF-8"%>
6!DOCTYPE HTML PBLIC"-//W3c//DTD HTML4.01 transitional//EN"
7"HTTP://www.w3.org/TR/html4/losse.dtd">
8
9<html>
10 <head>
11<meta http-equive="content-type" content="text/html;charset=UTF-8">
12<title>JSP page</title>
13</head>
14<body>
15<h1><%="HELLO world ! I'm a jsp,it is"+new java.util.data()%></h1>
16</body>
17</html>

          Reding inputparameters from the browser
when a brower submits a from,the request commonly parameter,that is,data
provided by the user.these parameter re avilable to a servlet througth the get parameter
method of the request variable,AS you have just seen,this means that a jsp also has
access to the same adata .prameters from are supplied in name/value pairs,and the
get parameter method takes that name as a lookup key,ND returns the associated value.

*the bulk of the documrnt is a regular HTML file;indeed ,it is entirely legal
 HTML.and can be editedin a WYSIWYG editor.
*Additional features related to the java aspects of the JSP are dented using the
<%........%>
*within<%......%>paies,three distinct variations are exemplified.these are:
      . comments(line1through3)
      . A"page directive"(line5)
      .an"expression"(line15)
the expression is computed using java and the resulit is converted toa string.that string is
then embedded into the onto HTML page to be partof the ouput that is sent to that browser.

1 comment:

Unknown said...

please tell me from where it is taking input in this form ?