Additional Capabilities of JSP Pages

A JSP page allows you to maintain state using cookies or session object. Session object is more used for maintaining state because it is reliable than cookies. A JSP page can forward requests to other JSP pages and Sites. It allows us to use Beans in a JSP Page.

A Simple JSP Page looks like the following:

<% @ page language=”java “%>

Arithmetic Operations

Arithmetic Operations

<% String s, oper; int s1, s2;

s=request.getParameter(“fno”);

s1=Integer.parseInt(s);

s=request.getParameter (“sno”);

s2=Integer.parseInt (s);

oper=request.getParameter (“submit”); %>

< % if (oper.equals (“add”) { % >

Result is :< % =s1+s2 %> <% } %>

< % if (oper.equals (“sub”) { % >

Result is :< % =s1-s2 %> <% } %>

< % if (oper.equals (“mul”) { % >

Result is :< % =s1*s2 %> <% } %>

< % if (oper.equals (“div”) { % >

Result is :< % =s1/s2 %> <% } %>

Save this Jsp page as oper.jsp.The html code for the above JSP page is as follows:

http://localhost:8080/oper.jsp”>

&nbsp

First First no:

Second no:

That's it!

The objects mentioned in the Architecture of the Java Server Pages section are shown in the example in bold:

  • The request object represents the user’s request.
The response object represents the response to the user.

ONLINE TRAINING

Dear friends we are happy to announce that we entered in corporate training. For the past two years we trained many students, Employees as per industrial requirements. Now we are started online training session for who dont have enough time and who dont want to waste time to come to institutes for learning. We are offering online sessions for Windows server 2003, windows server 2008, MCSE, .NET, Java. MS SQL Server and many more. For more details about course and fee structure please



Followers

Google Pagerank Powered by  MyPagerank.Net