Home Jsp INTRODUCTION TO JSP SCRIPTLETS
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

INTRODUCTION TO JSP SCRIPTLETS

Advertisement
JSP Scriptlets begins with <% and ends %> .

INTRODUCTION TO JSP SCRIPTLETS

     

Syntax of JSP Scriptles are:

  <%
  //java codes
   %>

JSP Scriptlets begins with <% and ends %> .We can embed any amount of java code in the JSP Scriptlets. JSP Engine places these code in the _jspService() method. Variables available to the JSP Scriptlets are:

  • request:
    request represents the clients request and is a subclass of HttpServletRequest. Use this variable to retrieve the data submitted along the request.
    Example:
      <%
      //java codes
       String userName=null;
       userName=request.getParameter("userName");
       %>
  • response:
    response is subclass of HttpServletResponse.
     
  • session:
    session represents the HTTP session object associated with the request.
     
  • out:
    out is an object of output stream and is used to send any output to the client.
Other variable available to the scriptlets are pageContext, application,config and exception.

INTRODUCTION TO JSP EXPRESSIONS

Syntax of JSP Expressions are:

  <%="Any thing"   %>

JSP Expressions start with 

Syntax of JSP Scriptles are with <%= and ends with  %>. Between these this you can put anything and that will converted to the String and that will be displayed.

Example:
  <%="Hello World!" %>
Above code will display 'Hello World!'.
  

Advertisement

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: February 13, 2008

Ask Questions?    Discuss: INTRODUCTION TO JSP SCRIPTLETS   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
janani.s
August 18, 2011
hi

i am beginer for this language. plz give me some detailed description about jsp
Siddharth Mishra
October 31, 2011
jsp codes

sir i want to know the jsp codes using expressions.
shraddha
November 2, 2011
convert this html form to jsp

<html> <head> <script language="javascript" src="images/validationm.js"></script> <script language="javascript" src="images/validation.js"></script> <title>Village Details</title> </head> <body bottommargin="2" leftmargin="10" rightmargin="10" topmargin="1" > <table align="center" cellSpacing=0 cellPadding=0 width="60%" border=0> <tbody> <tr> <td bgColor="#2a5865" colSpan=1> <IMG height=4 src="images/zero.gif" width=1> </td> </td> </tbody> </table> <table align="center" width="60%" height="100" > <tr> <td width="40%" height="100"> <p align="right" style="margin-top: 0; margin-bottom: 0"> <img src="images/avantha1.jpg" width="520" height="100"></p> </td> <td width="20%" height="100"> <p align="right" style="margin-top: 0; margin-bottom: 0"> <img src="images/logo[2].gif" width="200" height="100"></p> </td> </tr> </table> <body style="margin-left: 10pt; margin-right: 10pt; margin-bottom: 5pt" > <TD background="images/dot.gif"><IMG height=4 src="images/zero.gif" width=25></TD> </TR></TBODY></TABLE> <br> <table width="60%" height="40" border="0" cellpadding="6" cellspacing="0" align="center"> <tbody> <tr> <td valign="top" align="center" bgcolor="#2a5865"><font class="blackboldtxt"><font color="#ffffff" size=5><b>Add Village Details</b></font></font></td></tr> </td> </tr> <form name="VillageDetailsForm" action="AddVillage.jsp" method="post" onSubmit="return adsvalidate();"> <table width="50%" height="400" bgcolor="#ecf7fb" border="0" cellpadding="0" cellspacing="0" align="center"> <br> <tbody><tr><td colspan="2" align="center"><font class="textsmallbluenormal"><font color="#333333">All fields marked with <font color="#d36000">*</font> are mandatory.</font></font></td></tr> <tr> <script language="javascript" src="images/city.js"></script> <td style="padding-left: 15px; padding-top: 10px;" valign="middle" width="200"><font class="blackboldtxt"><font color="#003e7b">State :</font></font> <font class="smalltext"><font color="#d36000">*</font></font></td> <td style="padding-top: 10px;" valign="top"> <select style="width: 175px; font-family: arial,Verdana,sans-serif; font-size: 8pt;" class="textfiled" name="State" onChange="fillSelectFromArray(this.form.City, ((this.selectedIndex == -1) ? null : residingcity[this.selectedIndex-1]));getLocality();"> <option value="0" selected="selected"> ---------- Select State ---------- </option> <option value="1">Chhattisgarh</option> <option value="2">Madhya Pradesh</option> </select> </td> </tr> <tr> <td style="padding-left: 15px; padding-top: 10px;" valign="middle"> <font class="blackboldtxt"><font color="#003e7b">District :</font> <font class="smalltext"><font color="#d36000">*</font></font></font> </td> <td style="padding-top: 10px;" valign="top"> <input class="addtextfiled" size="25" name="District" value=""> </td> </tr> <tr> <td style="padding-left: 15px; padding-top: 10px;" valign="middle"> <font class="blackboldtxt"><font color="#003e7b">Tehsil/Taluka/Block :</font> <font class="smalltext"><font color="#d36000">*</font></font></font> </td> <td style="padding-top: 10px;" valign="top"> <input class="addtextfiled" size="25" name="Ttb" value=""> </td> </tr> <tr> <td style="padding-left: 15px; padding-top: 10px;" valign="middle"> <font class="blackboldtxt"><font color="#003e7b">Village :</font> <font class="smalltext"><font color="#d36000">*</font></font></font> </td> <td style="padding-top: 10px;" valign="top"> <input class="addtextfiled" size="25" name="VillageName" value=""> </td> </tr> <tr> <td style="padding-left: 15px; padding-top: 10px;" valign="middle"> <font class="blackboldtxt"><font color="#003e7b">Surpanch Name :</font></font> <font class="smalltext"><font color="#d36000">*</font></font></td> <td style="padding-top: 10px;" valign="top"> <input class="addtextfiled" size="25" name="SurpanchName" value=""> </td> </tr> <tr> <td style="padding-left: 15px; padding-top: 10px;" valign="middle"> <font class="blackboldtxt"><font color="#003e7b">No. Of HouseHolds :</font></font> <font class="smalltext"><font color="#d36000">*</font></font></td> <td style="padding-top: 10px;" valign="top"> <input class="addtextfiled" size="15" name="NumberOfHouseHolds" value=""> </td> </tr> <tr> <td style="padding-left: 15px; padding-top: 10px;" valign="middle"> <font class="blackboldtxt"><font color="#003e7b">No. Of Land Sellers :</font></font> <font class="smalltext"><font color="#d36000">*</font></font></td> <td style="padding-top: 10px;" valign="top"> <input class="addtextfiled" size="15" name="NumberOfLandLosers" value=""> </td> </tr> <tr> <td style="padding-left: 15px; padding-top: 10px;" valign="middle"> <font class="blackboldtxt"><font color="#003e7b">Total Village Area :</font></font> <font class="smalltext"><font color="#d36000">*</font></font></td> <td style="padding-top: 10px;" valign="top"> <input class="addtextfiled" size="15" name="TotalVillageArea" value=""> </td> </tr> <script type="text/javascript" src="images/automobile.js"></script> <tr> <td colspan="2" valign="top" align="middle"><br> <input name="file_name" value="newuser" type="hidden"> <input name="Country" value="" type="hidden"> <input name="reset" src="login.php_files/submit-button.gif" value="Clear" type="reset" width="62" border="0" height="19"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input name="post" src="login.php_files/submit-button.gif" value="Submit" type="submit" width="62" border="0"height="19" onClick='return check(frm)'> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input name="reset" src="login.php_files/submit-button.gif" type="reset" width="62" border="0" height="19" value="Cancel"> </td> </tr> </tbody> </table> </form> </td> </tr> </tbody> </table> <!-- End of New Village Registration --> </body></html>
Arun Seth
February 21, 2012
Which compiler to use to make a Website in java

I want to make a website based project in java, but i am not able to find which compiler to use for it, and how to make the project. Please help me out!!!
Asiimwe
March 22, 2012
GeggQoRsBXzsYHg

The voice of ratniolatiy! Good to hear from you.
KishanKumar
August 20, 2012
Different Types of Scriptlet

What are the types of Scriptlet? What is the technical name for <% %>, <%= %>, <%! %>.
DMCA.com