.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Articles >> General >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Using Request in Jsp

Posted By:satyapriyanayak       Posted Date: August 31, 2014    Points: 200    Category: General    URL: http://www.dotnetspark.com  

In this article we will know about the use request object in jsp

Java server pages use request of the user with the help of request object. This is an object of javax.servlet.httpServletRequest.This object is available as the first parameter of _jspService () method present in the servlet generated behind the jsp. All methods of httpservletRequest can be used upon request object. The form tag needs to use name of the jsp file as the value of its action attribute.

Example: - Using request object to determine whether a number is even or odd.

<body bgcolor="pink">
     String str=request.getParameter("t1");
<h2>Enter a Number<input type="text" name="t1"></h2>
<input type="submit" value="submit">
    int x=Integer.parseInt(str);
      if(x %2==0)
<h1>The Number <font color="red"><%= x %></font>  is even </h1>
<h1>The Number <font color="red"><%= x %></font>  is odd </h1>

 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend