Package examples.jsp

This example shows how to use JSP to generate dynamic content in web pages.


 

JSP Examples Summary

EJBeanManagedClient Demonstrates using JSP to call a WebLogic EJBean, how to use an EJBean from within a scriplet page. It uses a beanManaged entity EJBean included with the WebLogic Distribution. Before you try to run this example, you will need to compile, configure, and deploy the EJBean that this example depends upon; please see the beanManaged persistence example and the WebLogic EJBean examples for instructions.
HelloWorld This simple example demonstrates how to embed Java in a JSP page.
InteractiveQuery Connects to a database, and displays it's contents in a table. You can click on an entry in the table, which makes another query to this JSP page. The page interprets the request differently since there are HTTP query parameters present, and displays the name of the entry you selected.
JdbcTable Shows how to use a form to set options for retrieving database data from a table with JDBC. Uses the demoPool JDBC connection pool.
SessionServlet Shows how to store and retrieve user data in a session. The example allows you to add or delete name/value attributes to and from an HTTP session, much the same as a shopping cart would work. The same session containing the user values is retrieved each time the browser revisits the web page, and is displayed in a list. This is achieved using session cookies. For more details, see the section on sessions in Programming WebLogic HTTP Servlets.
ShowDate Demonstrates importing a package (java.util.Date) into a JSP page, setting a response header attribute, and using a JSP expression tag.
SimpleDBLogin Illustrates how to make a connection to a database with JDBC, including exception handling to help you debug your servlet. Uses the "demoPool" JDBC connection pool.
SimpleSession Shows simple principles of session management by incrementing a counter each time a user accesses a page.
SnoopServlet Lets you examine HTTP data about the servlet itself.
ThrowException Demonstrates how to set up an error page for a JSP page. Here, ErrorPage.jsp is returned when an uncaught exception is thrown in the ThrowException.jsp page.
URLEncode Demonstrates using URL rewriting to pass session information to the server from browsers that do not support cookies.
Using JSP Custom Tag Libraries A set of examples that demonstrate using custom JSP tags and how to create the Java classes for the tags.

 

Package jsp Description

Examples that show how to use JSP to generate dynamic content in web pages. JSP allows you to concentrate on the design of html pages, but still use Java to provide the dynamic content and logic.

Perform the following steps to build and run the examples:

  1. Build the examples
  2. Configure the server
  3. Run the example

 

Build the Examples

  1. Set up your development shell as described in Setting up your environment for building and running the examples.

  2. Copy all the .jsp files by executing the following command or by executing the build script provided for this example in the SAMPLES_HOME\server\examples\src\examples\jsp directory. The script will copy the .jsp files located in the samples\examples\jspg directory in your WebLogic Server installation to the SAMPLES_HOME\server\examples\build\examplesWebApp directory in your WebLogic Server installation. This directory is the location of the publically-available files of the examplesWebApp.

    prompt> copy *.jsp %SAMPLES_HOME%\server\examples\build\examplesWebApp

 

Configure the Server

  1. Start the server with the examples configuration.

  2. Bring up the Administration Console in your browser.

  3. Make sure that the examplesWebApp is deployed on your server.

  4. Make sure that the demoPool JDBC connection pool is deployed on the "examplesServer" target. Use the WebLogic Server Administration Console to deploy this connection pool.

    Many of the examples use JDBC to access an example PointBase database called "Demo."

 

Run the Example

  1. Start the WebLogic Server in a new command shell.

  2. Use a browser to call the JSP page, with a URL that follows the pattern:

      http://WebLogicURL:WebLogicPort/examplesWebApp/jspExample.jsp
    For example, this is how you load the HelloWorld example in a browser running on the same NT host as your WebLogic Server, on port 7001:

    http://www.setgetweb.com:7001/examplesWebApp/HelloWorld.jsp