All Examples  This Package  JMS Examples

Class examples.jms.webshare.WebshareServlet

examples.jms.webshare.WebshareServlet

public class WebshareServlet
This example is a servlet that allows users to rate web pages and receive other users' web page ratings. It demonstrates these features of JMS:

Any user can publish a web page rating. The servlet requires users to log in with a ClientID. This ClientID is used to reconnect a TopicSubscriber so that the user can receive all of the messages posted. The ClientID is also used in messages to identify the user who published the web page rating.

Configure the server:

  1. Set weblogic.httpd.session.enable=true in the weblogic.properties file.
  2. You must have a connection pool configured and assigned to JMS in the weblogic.properties file. See JMS Examples for instruction on how to set up a connection pool for JMS.
  3. Set up a JMS Topic and a Durable ClientID by adding these properties to your weblogic.properties file:
       weblogic.jms.topic.webshareTopic=jms.topic.webshareTopic
       weblogic.jms.connectionFactoryName.webshare=jms.connection.webshareFactory
       weblogic.jms.connectionFactoryArgs.webshare=ClientID=webshareUser
  4. Register the servlet in your weblogic.properties file by adding this property:
      weblogic.httpd.register.webshare=examples.jms.webshare.WebshareServlet
  5. Set the servlet classpath and reload properties in your weblogic.properties file by adding the following properties:
      weblogic.httpd.servlet.classpath=weblogic/myserver/servletclasses
      weblogic.httpd.servlet.reloadCheckSecs=1
    where weblogic is the directory where WebLogic is installed.
Build the example:
  1. Set up your development shell, as described in Setting up your environment.
  2. Compile the files in this directory as shown in this examples for Windows NT:
      $ javac -d %SERVLET_CLASSES% WebshareServlet.java
Run the example:
  1. Start the WebLogic Server in a new command shell.
  2. Load the servlet in a browser with a URL like this:
      http://hostname:port/webshare
    where:
    hostname
    Host name of the WebLogic Server
    port
    Port where the WebLogic Server is listening for connections (weblogic.system.ListenPort).
  3. Log in to establish a session with the servlet. Then you can choose to rate web pages, view the posted web page listings, or change your subscription information.

Author:
Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights Reserved.

Variable Index

 o JMS_FACTORY
 o MESSAGE_TYPE
 o TOPIC

Constructor Index

 o WebshareServlet()

Method Index

 o editSubscription(PrintWriter, String)
Create a DurableSubscription and MessageSelector for the current logged in user.
 o getLogin(PrintWriter)
Draws the login HTML page.
 o getOptions(PrintWriter)
Sticks standard buttons on the bottom of pages.
 o getRatings(PrintWriter, String)
Reads website recommendations from the webshareTopic JMS Topic.
 o installSelector(PrintWriter, String, String, int, String)
Create a selector string and update the user's DurableSubscription
 o printForm(PrintWriter, String)
Displays the website review form.
 o service(HttpServletRequest, HttpServletResponse)
 o shareUrl(String, String, int, String, String, String)
Publishes a website review to the webshareTopic Topic.

Variables

 o JMS_FACTORY
 public static final String JMS_FACTORY
 o TOPIC
 public static final String TOPIC
 o MESSAGE_TYPE
 public static final String MESSAGE_TYPE

Constructors

 o WebshareServlet
 public WebshareServlet()

Methods

 o service
 public void service(HttpServletRequest req,
                     HttpServletResponse res) throws IOException, ServletException
 o getLogin
 public void getLogin(PrintWriter pw) throws Exception
Draws the login HTML page.

 o getOptions
 public void getOptions(PrintWriter pw) throws Exception
Sticks standard buttons on the bottom of pages. Pressing one of these buttons determines which post method the service() method is going to process.

 o printForm
 public void printForm(PrintWriter pw,
                       String login) throws Exception
Displays the website review form.

 o shareUrl
 public void shareUrl(String user,
                      String category,
                      int rating,
                      String summary,
                      String pagetitle,
                      String url) throws NamingException, JMSException
Publishes a website review to the webshareTopic Topic.

 o editSubscription
 public void editSubscription(PrintWriter pw,
                              String user) throws NamingException, JMSException, Exception
Create a DurableSubscription and MessageSelector for the current logged in user.

 o installSelector
 public void installSelector(PrintWriter pw,
                             String userName,
                             String posters,
                             int minRating,
                             String categoryList) throws NamingException, JMSException, Exception
Create a selector string and update the user's DurableSubscription

 o getRatings
 public void getRatings(PrintWriter pw,
                        String user) throws NamingException, JMSException, Exception
Reads website recommendations from the webshareTopic JMS Topic. Creates a DurableSubscriber for whomever is logged in.


All Examples  This Package  JMS Examples