Saturday, 2 December 2017

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>


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

No comments:

Post a Comment

Welcome, happy learning

Charactor_At_Position

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