Saturday, 2 December 2017

How to get Factorial Number Program Java

Learning Java Programming Made Easy


  1. class FactorialExample{  
  2.  public static void main(String args[]){  
  3.   int i,fact=1;  
  4.   int number=5;//It is the number to calculate factorial    
  5.   for(i=1;i<=number;i++){    
  6.       fact=fact*i;    
  7.   }    
  8.   System.out.println("Factorial of "+number+" is: "+fact);    
  9.  }  
  10. }  

How to get palindrome Number Program in java programming

Learning Java Programming Made Easy



  1. class PalindromeExample{  
  2.  public static void main(String args[]){  
  3.   int r,sum=0,temp;    
  4.   int n=454;//It is the number variable to be checked for palindrome  
  5.   
  6.   temp=n;    
  7.   while(n>0){    
  8.    r=n%10;  //getting remainder  
  9.    sum=(sum*10)+r;    
  10.    n=n/10;    
  11.   }    
  12.   if(temp==sum)    
  13.    System.out.println("palindrome number ");    
  14.   else    
  15.    System.out.println("not palindrome");    
  16. }  
  17. }  

How to get Prime number using Java Programming

Learning Java Programming Made Easy


  1. public class PrimeExample{    
  2.  public static void main(String args[]){    
  3.   int i,m=0,flag=0;      
  4.   int n=3;//it is the number to be checked    
  5.   m=n/2;      
  6.   if(n==0||n==1){  
  7.    System.out.println(n+" is not prime number");      
  8.   }
  9. else{  
  10.    for(i=2;i<=m;i++){      
  11.     if(n%i==0){      
  12.      System.out.println(n+" is not prime number");      
  13.      flag=1;      
  14.      break;      
  15.     }      
  16.    }      
  17.    if(flag==0)  { System.out.println(n+" is prime number"); }  
  18.   }//end of else  
  19. }    
  20. }   

How to get Fibonaci Series in JAVA Programming

Learning Java Programming Made Easy


  1. class FibonacciExample1{  
  2. public static void main(String args[])  
  3. {    
  4.  int n1=0,n2=1,n3,i,count=10;    
  5.  System.out.print(n1+" "+n2);//printing 0 and 1    
  6.     
  7.  for(i=2;i<count;++i)//loop starts from 2 because 0 and 1 are already printed    
  8.  {    
  9.   n3=n1+n2;    
  10.   System.out.print(" "+n3);    
  11.   n1=n2;    
  12.   n2=n3;    
  13.  }    
  14.   
  15. }
  16. }

How to use SWITCH case statement in java jsp Programming

Learning Java Programming Made Easy


SWITCH case statement in java jsp Programming


<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    
    <%
         //<editor-fold defaultstate="collapsed" desc="comment">
int day
//</editor-fold>
=Integer.parseInt(request.getParameter("enterno")); 
        
      
       
switch(day) {
case 0:
   out.println("It\'s Sunday.");
   break;
case 1:
   out.println("It\'s Monday.");
   break;
case 2:
   out.println("It\'s Tuesday.");
   break;
case 3:
   out.println("It\'s Wednesday.");
   break;
case 4:
   out.println("It\'s Thursday.");
   break;
case 5:
   out.println("It\'s Friday.");
   break;
default:
   out.println("It's Saturday.");
}
%>
</html>

How to get session using java jsp programming code

Learning Java Programming Made Easy

get session using java jsp programming code 

Page 1:

/***********************************************//

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
   
    <body>
         
        <%
        String username=request.getParameter("username");
        //String password=request.getParameter("password");
        out.println("welcome : "+username);
      //  session.setAttribute("user",username);     
        %>
        <a href="sessionsecond.jsp?user=<%=username%>">gotonextpage</a>
    </body>
</html>

/**********************************************//


Page 2:

/**********************************************//
<%-- 
    Document   : sessionsecond
    Created on : Dec 7, 2016, 11:13:13 AM
    Author     : admin
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%
            //String usermname=session.getAttribute("user").toString();
            String name=request.getParameter("user");
            String pass=request.getParameter("pass");
          out.println("Welcome : "+name);
        %>
        <a href="sessionthird.jsp">gotonextpage</a>
    </body>
</html>

/********************************************//


Page 3:

/***************************************//

<%-- 
    Document   : sessionstartpage
    Created on : Dec 7, 2016, 11:09:47 AM
    Author     : admin
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <form action="sessionfirstppag.jsp" method="post"> 
            <input type="text" name="username"><br/>
            <input type="text" name="password"><br/>
            <input type="submit" value="go">
        </form>
    </body>
</html>

/***************************************//

Page 4:

/****************************************//

<%-- 
    Document   : sessionthird
    Created on : Dec 7, 2016, 11:17:50 AM
    Author     : admin
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
       <%
            //String usermname=session.getAttribute("user").toString();
            String usermname=request.getParameter("user");
          out.println("welcome : " +usermname);
        %>
    </body>
</html>


/******************************************//

How to include one jsp file into another jsp file body to display data java jsp programming code

Learning Java Programming Made Easy


Page 1: Hit Counter (jsp page)

/*******hits.jsp*******//
<%-- 
    Document   : hits
    Created on : Nov 30, 2016, 11:54:25 AM
    Author     : admin
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<body>
<%
    Integer hitsCount = (Integer)application.getAttribute("hitCounter");
    if( hitsCount ==null || hitsCount == 0 ){
       out.println("first time!");
       hitsCount = 1;
    }else{
       /* return visit */
       out.println("Welcome back!");
       hitsCount += 1;
    }
    application.setAttribute("hitCounter", hitsCount);
%>
<p>Total number of visits: <%= hitsCount%></p>
</body>
</html>



/***********************************************************//


Page 2: (jsp file)


/************main.jsp**************/


<%-- 
    Document   : main
    Created on : Nov 30, 2016, 12:04:52 PM
    Author     : admin
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<body>
<jsp:include page="hits.jsp" flush="true" />
</body>
</html>



How to use get and set property in java jsp programming

Learning Java Programming Made Easy



<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<body>
<jsp:useBean id="test" class="action.testbean" />
<jsp:setProperty name="test" 
                    property="message" 
                    value="Hello JSP..." />
<jsp:getProperty name="test" property="message" />
</body>
</html>

how to use java program for website HIT Counter java jsp programming code

Learning Java Programming Made Easy






<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="java.io.*,java.util.*" %>

<html>
<body>
<%
    Integer hitsCount = (Integer)application.getAttribute("hitCounter");
    if( hitsCount ==null || hitsCount == 0 ){
       out.println("first time!");
       hitsCount = 1;
    }else{
       /* return visit */
       out.println("Welcome back!");
       hitsCount += 1;
    }
    application.setAttribute("hitCounter", hitsCount);
%>
<p>Total number of visits: <%= hitsCount%></p>
</body>
</html>

How to use checkbox program in java jsp

Learning Java Programming Made Easy

Page 1:


<%-- 
    Document   : check
    Created on : Feb 9, 2017, 11:40:10 AM
    Author     : my pc
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<body>
    <form action="checkcall.jsp" method="POST" target="_blank">
    <input type="checkbox" name="a" checked="checked" /> A
    <input type="checkbox" name="b"  /> B
    <input type="checkbox" name="c" checked="checked" /> C
<input type="submit" value="Select Subject" />
</form>
</body>
</html>



/************************************************************************/



Page 2:


<%-- 
    Document   : checkcall
    Created on : Feb 9, 2017, 11:40:30 AM
    Author     : my pc
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<body>
<b>A Flag:</b><%= request.getParameter("a")%>
<b>B Flag:</b><%= request.getParameter("b")%>
<b>C Flag:</b><%= request.getParameter("c")%>
</body>
</html>

Charactor_At_Position

public class Char_At_Position { public static void main(String[] args) { String str = "Wankhede"; String rev=""...