All Examples Tag Extension Examples
JavaServer Pages (JSP) examplesHere's an alphabetical list of the JSP example linking to a short description below. The example descriptions are ordered by complexity.
JSP tag library extension examples are provided in the tagext sub-directory.
about the JSP examples . . .
These examples 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. These examples demonstrate:
- Using JSP to develop interactive web pages
- Using Java variables at different scopes
- Responding to user input through an HTML form
- Using HTTP sessions to track user input
- Using database data with JDBC and dbKona
- Rewriting URLs for browsers that don't support cookies
Here is a short description of each JSP example, ordered by complexity. The (run) link after each page will request the actual JSP page itself. This link will only work if you are requesting the JSP page the WebLogic Server. Setup instructions are described below.
- HelloWorld.jsp (listing) (run)
- This simple example demonstrates how to embed Java in a JSP page.
- ShowDate.jsp (listing) (run)
- Demonstrates importing a package (java.util.Date) into a JSP page, setting a response header attribute, and using a JSP expression tag.
- ErrorPage.jsp (listing) (run) & ThrowException.jsp (listing) (run)
- 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.
- SimpleDBLogin.jsp (listing) (run)
- Illustrates how to make a connection to a database with JDBC, including exception handling to help you debug your servlet. This example requires you to set up the "demoPool" Cloudscape database, as described in the techsupport document Using the Cloudscape database with WebLogic.
- EasyTableDataDisplay.jsp (listing) (run)
- Shows how to create an HTML table from a dbKona TableDataSet with minimum effort. This example uses a handy feature of htmlKona that creates an HTML table automatically from a JDBC DataSet. To run the example, you will need to set up the demoPool JDBC connection pool, as described below.
- InteractiveQuery.jsp (listing) (run)
- 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.jsp (listing) (run)
- Shows how to use a form to set options for retrieving database data from a table with JDBC. This example uses the demoPool JDBC connection pool, as described below.
- SessionServlet.jsp (listing) (run)
- 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 Using session tracking from a servlet.
- SnoopServlet.jsp (listing) (run)
- Lets you examine HTTP data about the servlet itself.
- URLEncode.jsp (listing) (run)
- Demonstrates how URL rewriting works, for passing session information to the server from browsers that don't support cookies.
- EJBeanManagedClient.jsp (listing) (run)
- Demonstrates using JSP to call a WebLogic EJBean, how to use an EJBean from within a scriplet page. It uses a bean-managed entity EJBean included with the WebLogic Distribution. Before you try to run this example, you'll need to compile, configure, and deploy the EJBean that this example depends upon; please see the bean-managed persistence example and the WebLogic EJBean examples for instructions.
- JSP Tag Extensions (go to example page)
- JSP1.1 allows you to create custom JSP tags for use in your JSP pages. These provide the best means to encapsulate dynamic content logic and provide a cleaner interface to the HTML design of the web page. These examples are provided in the sub-directory tagext.
how to use this package
- In the weblogic.properties file of your WebLogic Server, you must enable JSP pages. Look for and un-comment the following lines:weblogic.httpd.register.*.jsp=\ weblogic.servlet.JSPServlet weblogic.httpd.initArgs.*.jsp=\ pageCheckSeconds=1,\ compileCommand=c:/java/bin/javac.exe,\ workingDir=/weblogic/myserver/classfiles,\ verbose=trueTo run these examples, ensure that compileCommand points to a valid java compiler. For more details on setting up JSP in WebLogic, see the administrators guide, Setting up JSP.
- Many of the examples use JDBC to access an example Cloudscape database called "demoPool". The Cloudscape DBMS and a default database are provided with the WebLogic Server installation. For more details on how to configure Cloudscape and the example "demoPool" database, see the tech-support document Using the Cloudscape database with WebLogic.
- Make sure that the document root is configured correctly. Look for the property:weblogic.httpd.documentRoot=public_htmlYour JSP files must live below the document root directory. The document root is the top level directory for files that are publically available on your WebLogic Server, and it is the root directory where JSP files are searched from. For more details, see Setting up a document root.
Set your document root to public_html (as above), then copy this entire examples\jsp directory to C:\weblogic\myserver\public_html\jsp.
- Start the WebLogic Server on your local machine, and request this page again via the URL: http://localhost:7001/jsp/index.html. You are now requesting all HTML and JSP files via the WebLogic Server, and will be able to simply click on the (run) links above to run the JSP files.
- To call a page, access the page using a URL such as:http://localhost:7001/jsp/HelloWorld.jspor click on the (run) links above once you have requested this example page via the WebLogic Server running on your local machine.
- Read more about JSP in the Developers Guide, Using WebLogic JSP.
- There is an example that uses the <jsp:plugin> tag in the applet examples.
- We provide a number of custom JSP tag extension library examples in a the tagext sub-directory.
- Other Developers Guides that may be of interest for the examples in this directory are:
- There are also Developers Guides for each of the JDBC drivers.
Copyright © 1999-2000 BEA Systems, Inc. All rights reserved.
Last updated 11/24/1999