0% found this document useful (0 votes)
45 views

Retrieving The Data Posted To A JSP File From HTML File

The document describes how to retrieve data posted from an HTML form in a JSP page. An HTML file called getname.htm contains a form that prompts the user to enter their name. This form posts to a JSP page called showname.jsp. To retrieve the entered name, showname.jsp uses the request.getParameter("username") method, which retrieves the value of the "username" parameter posted from the HTML form. The JSP page then displays "Welcome" and the retrieved name.

Uploaded by

ganesa.prabu
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

Retrieving The Data Posted To A JSP File From HTML File

The document describes how to retrieve data posted from an HTML form in a JSP page. An HTML file called getname.htm contains a form that prompts the user to enter their name. This form posts to a JSP page called showname.jsp. To retrieve the entered name, showname.jsp uses the request.getParameter("username") method, which retrieves the value of the "username" parameter posted from the HTML form. The JSP page then displays "Welcome" and the retrieved name.

Uploaded by

ganesa.prabu
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Retrieving the data posted to a JSP file from HTML file

Now I will show you how to retrieve the data posted from a HTML file in a JSP page. Consider an html page that prompts the user to enter his/her name, let's call it getname.htm. Here is the code of the html file <html> <head> <title>Enter your name</title> </head> <body> <p>&nbsp;</p> <form method="POST" action="showname.jsp"> <p><font color="#800000" size="5">Enter your name:</font><input type="text" name="username" size="20"></p> <p><input type="submit" value="Submit" name="B1"></p> </form> </body> </html> The target of form is "showname.jsp", which displays the name entered by the user. To retrieve the value entered by the user we uses the request.getParameter("username"); code. Here is the code of "showname.jsp" file: <%@page contentType="text/html" %> <!-http://www.roseindia.net/jsp --> <html> <body> <p><font size="6">Welcome :&nbsp; <%=request.getParameter("username") %></font></p> </body>

</html>

JSP FUNDAMENTALS
JSP page is built using components such as :

Directives Declarations Scriplets Expressions Standard Actions Custom Tags

Directives :
Listing some of them to start off : 1) Page Syntax : < %@ page Language=Java extends=<Class name> import=<class> or
<package> %>

Attributes: a. Language = Java b. Import = Class c. Buffersize = d. Scope = REQUEST/PAGE/SESSION/APPLICATION e. And etc. Page directive is aimed to define certain attribute of a JSP page for e.g. Language of the page in which the page content should be written , which class to be imported so that it can be used within the JSP page. 2) Include Syntax: <%@ include file=<filename> %> Attributes: a. file = <filename> This directive is to include the a HTML, JSP or Sevlet file into a JSP file. This is a static inclusion of file i.e. it will be included into the JSP file at the time of compilation and once the JSP file is compiled any changes in the included the file will not the reflected.

Declarations:

Syntax: <%! Declare all the variables here %>

Scriplets:
Syntax: <% All your scripts will come here %>

Expressions:

You might also like