Daniel M. Hendricks

Reading Form Submission Variables

You use the request.getParameter() method in JSP to request form submissions variables, similar to the Request.Form() method in VBscript ASP.



<% out.print("myfield=" + request.getParameter("myfield")); %>

Note: Make sure the “action=” attribute matches the name of the file you paste this code into.

Declaring and Reading Session Variables

Use the session.setAttribute() method to set a session variable:

<%
session.setAttribute( "mySessionVariable", "Hello World" );
%>

Use the session.getAttribute() method to retrieve the value of a session variable:

<%= session.getAttribute( "mySessionVariable" ) %>

This will return the following:
Hello World

Post a Comment

You must be logged in to post a comment.

Tip: Sign up for a free Gravatar to have a photo next to your comment! Your gravatar will follow you around when you post to blogs that support it, based on the e-mail address you use to post.