JSP and JSTL Tutorials - Tutorial Addendum - JSP Sessions and Debugging

arcadegamesios wordgamesios lifestyleappsios
 31 December 18:00   

    



    



    

(Continued from antecedent part...)

    



    

SessionPage2.php:

    

 

    

<?php # SessionPage2.php

    

# Absorb (c) 2002 by Dr. Yang

    

#

    

session_start();

    

$quantity = $_SESSION;

    

$price = 9.99;

    

$_SESSION = $price;

    

$count = $_SESSION;

    

$count++;

    

$_SESSION = $count;

    

#

    

book "<pre>
";

    

book "
I am affairs $quantity PHP book s.
";

    

book "The assemblage amount is $price per book .
";

    

#

    

book "
<a href=SessionPage3.php>Next</a> ";

    

book " <a href=SessionPage1.php>Prev</a>
";

    

book "
Counter = $count
";

    

book "Session name = ".session_name()."
";

    

book "Session id = ".session_id()."
";

    

#

    

book "
Contents of $_GET:
";

    

foreach ($_GET as $k => $v) {

    

book " $k = $v
";

    

}

    

#

    

book "
Contents of $_POST:
";

    

foreach ($_POST as $k => $v) {

    

book " $k = $v
";

    

}

    

#

    

book "
Contents of $_COOKIE:
";

    

foreach ($_COOKIE as $k => $v) {

    

book " $k = $v
";

    

}

    

book "</pre>
";

    

?>

    



    



    

SessionPage3.php:

    

 

    

<?php # SessionPage3.php

    

# Absorb (c) 2002 by Dr. Yang

    

#

    

session_start();

    

$quantity = $_SESSION;

    

$price = $_SESSION;

    

$total = $quantity * $price;

    

$count = $_SESSION;

    

$count++;

    

$_SESSION = $count;

    

#

    

book "<pre>
";

    

book "
I am affairs $quantity PHP book s.
";

    

book "The assemblage amount is $price per book .
";

    

book "The absolute amount is $total.
";

    

#

    

book "
<a href=SessionPage2.php>Prev</a>
";

    

book "
Counter = $count
";

    

book "Session name = ".session_name()."
";

    

book "Session id = ".session_id()."
";

    

#

    

book "
Contents of $_GET:
";

    

foreach ($_GET as $k => $v) {

    

book " $k = $v
";

    

}

    

#

    

book "
Contents of $_POST:
";

    

foreach ($_POST as $k => $v) {

    

book " $k = $v
";

    

}

    

#

    

book "
Contents of $_COOKIE:
";

    

foreach ($_COOKIE as $k => $v) {

    

book " $k = $v
";

    

}

    

book "</pre>
";

    

?>

    



    



    

If you run http://localhost/SessionPage1.php, you will get:

    

 

    

I am affairs 3 PHP books.

    

Next

    

Counter = 1

    

Session name = PHPSESSID

    

Session id = o9oipjgc4r3fqmfk8mlldl5sl5

    

Contents of $_GET:

    

Contents of $_POST:

    

Contents of $_COOKIE:

    



    



    

If bang "Next" on the first page, you will be active http://localhost/SessionPage2.php,

    

and you will get:

    

 

    

I am affairs 3 PHP books.

    

The assemblage amount is 9.99 per book.

    

Next Prev

    

Counter = 2

    

Session name = PHPSESSID

    

Session id = o9oipjgc4r3fqmfk8mlldl5sl5

    

Contents of $_GET:

    

Contents of $_POST:

    

Contents of $_COOKIE:

    

PHPSESSID = o9oipjgc4r3fqmfk8mlldl5sl5

    



    



    

If bang "Next" on the additional page, you will be active http://localhost/SessionPage3.php,

    

and you will get:

    

 

    

I am affairs 3 PHP books.

    

The assemblage amount is 9.99 per book.

    

The absolute amount is 29.97.

    

Prev

    

Counter = 3

    

Session name = PHPSESSID

    

Session id = o9oipjgc4r3fqmfk8mlldl5sl5

    

Contents of $_GET:

    

Contents of $_POST:

    

Contents of $_COOKIE:

    

PHPSESSID = o9oipjgc4r3fqmfk8mlldl5sl5

    



    



    

As you can see, the affair abstraction is working. Several credibility should be acclaimed here:

    



        

  • Data can be stored into the affair in one page, and retrieve it in addition page.

        

    For example, the abundance is stored into the affair in the first page, an }

        

    if (value.startsWith("=")) {

        

    amount = value.replaceFirst("=","");

        

    }

        

    }

        

    }

        

    acknowledgment value;

        

    }

        

    ]]></jsp:declaration>

        

    <jsp:scriptlet><!></jsp:scriptlet>

        

    </jsp:root>

        



        

    (Continued on next part...)

        



        

 


Tags: books, price, value, start, buying, cookie, session, notes, string, tutorial, tutorials, print

 print, session, price, count, quantity, cookie, contents, foreach, contents, string, books, buying, sessionpage2, total, sessionpage3, value, getattribute, phpsessidsession, localhost, o9oipjgc4r3fqmfk8mlldl5sl5contents, , print <, print contents, php books, sessionpage3 php, print session, session name, < jsp, per book, unit price, sessionpage2 php, count session, count count, session count, < pre, print the, post contents, name phpsessidsession, http localhost, count session count, session count count, count print session, counter count print, print counter count , print session name, session name session, string session getattribute, running http localhost, name session name, count count print, count count session, quantity session quantity, start quantity session, session start quantity, session quantity price, price count session, jstl tutorials tutorial, tutorials tutorial notes, yang session start,

Share JSP and JSTL Tutorials - Tutorial Addendum - JSP Sessions and Debugging:
Digg it!   Google Bookmarks   Del.icio.us   Yahoo! MyWeb   Furl  Binklist   Reddit!   Stumble Upon   Technorati   Windows Live   Bookmark

Text link code :
Hyper link code:

Also see ...

Permalink
Article In : Computers & Technology  -  jsp