Simple Programs in JSP

 

JSP is dynamic programming language. It is capable of making simple program to complex. We can make simple program of add, even numbers, odd numbers. It is good start for beginner to learn with these programs.

First program of adding two numbers in JSP

<%@ page language="java"%>
<html>
<head>
<title>Add number program in JSP</title>
</head>

<body>
<%
 int a=5;
 int b=2;
 
 int result=a+b;
  
 out.print("Additon of a and b :"+result); 
%>
</body>
</html>

Second program of subtraction two numbers in JSP

<%@ page language="java"%>
<html>
<head>
<title>Subtraction numbers program in JSP</title>
</head>

<body>
<%
 int a=5;
 int b=2;
 
 int result=a-b;
  
 out.print("Subtraction of a and b :"+result); 
%>
</body>
</html>

Third program of print even numbers in JSP

<%@ page language="java"%>
<html>
<head>
<title>Even number program in JSP</title>
</head>

<body>
<%
 for(int i=0;i<=10;i++) 
 {
  if((i%2)==0)
  {
   out.print("Even number  :"+i); 
   out.print("<br>");
  }
 }
%>
</body>
</html>

Forth program of print odd numbers in JSP

<%@ page language="java"%>
<html>
<head>
<title>Odd number program in JSP</title>
</head>

<body>
<%
 for(int i=0;i<=10;i++) 
 {
  if((i%2)!=0)
  {
   out.print("Odd number  :"+i); 
   out.print("<br>");
  }
 }
%>
</body>
</html>

Tags:

 

20 Responses to “Simple Programs in JSP”

  1. plz mail me jsp example program

  2. saleem says:

    The actual purpose of jsp is only for presentation, well done but how to separate our presention logic and business logic, for that we can write that in action class, pls mail me with that example

  3. shivanand says:

    Sir plese send core java and jsp examples with comments to my mail id.for having expertise. i hgave more interest to become java developer. Thank you

  4. raju swargam says:

    it is very good. very usefull to every programer.

  5. raju swargam(SANDHYARAJ) says:

    sir, this is very nice. but i need much clarification about servlet.

  6. jack says:

    how to complie the jsp

  7. lalitha says:

    please send all best j2ee examples to my id

  8. priti says:

    good exampe for bignner

  9. bunny says:

    plz send me the execution process of jsp progrms..

  10. Guna says:

    hi send me the execution process of jsp.
    And how execute manualy.

  11. venkatesh says:

    it’s so good but need much clarification

  12. bhuvaneshwari says:

    i need to ejbbeans sample programs

  13. vamsi says:

    PLEASE SEND JSP PROGRAMS CLEARLY . HOW CREATE HTML FILE AND JSP FILE. AND HOW TO RUN JSP PROGRAM BY USING TOMCAT 6.0.

  14. durga.g says:

    jsp examples are good…
    wil u provide more information how javascript differ from jsp?

  15. paulin says:

    how can we complie the jsp program?

  16. Anbu says:

    how to connect jsp to postgres sql?????
    plz replay me
    with sample small coding……….

  17. Manvendra Sharma says:

    sir please send the information about jsp servlet,and how this concatenate with ajax .send some example.i am waiting