Class sun.server.http.ImagemapServlet
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sun.server.http.ImagemapServlet

java.lang.Object
   |
   +----java.servlet.GenericServlet
           |
           +----java.servlet.http.HttpServlet
                   |
                   +----sun.server.http.ImagemapServlet

public class ImagemapServlet
extends HttpServlet
Servlet for handling server-side imagemap requests

Constructor Index

 o ImagemapServlet()
Creates a new imagemap servlet.

Method Index

 o distanceSquared(Point, Point)
Calculates the square of the Euclidian distance between two points
 o getServletInfo()
Returns information about the servlet
 o main(String[])
 o parseMapFile(HttpServletRequest, HttpServletResponse, Point, File)
This function parses the requested mapfile a determines the URL associated with the clicked point.
 o parseMenuText(StreamTokenizer, URL, String, String)
Reads in the optional text that is display on text only browsers
 o parsePoint(StreamTokenizer)
Parses and returns a point from the input stream.
 o pointInCircle(Point, Point, Point)
Checks if the given point is within the bounds of the specified circle
 o pointInPoly(Point, Vector)
Checks if the given point is within the bounds of the specified polygon
 o pointInRect(Point, Point, Point)
Checks if the given point is within the bounds of the specified rectangle
 o sendErrorResponse(HttpServletResponse, String)
Returns an error message to the user if some error occured while processing the imagemap request
 o sendMenuResponse(HttpServletResponse, String)
Responds with a textual menu of all available links in the mapfile
 o sendResponse(HttpServletResponse, URL)
Returns a redirect response with the proper URL, or a "no content" response if no matching URL could be found
 o service(HttpServletRequest, HttpServletResponse)
Services a single imagemap request from the client.

Constructors

 o ImagemapServlet
  public ImagemapServlet()
Creates a new imagemap servlet.

Methods

 o service
  public void service(HttpServletRequest req,
                      HttpServletResponse res) throws ServletException, IOException
Services a single imagemap request from the client.
Parameters:
req - the HTTP request
res - the HTTP response
Throws: IOException
If an I/O error has occurred.
Overrides:
service in class HttpServlet
 o parseMapFile
  public void parseMapFile(HttpServletRequest req,
                           HttpServletResponse res,
                           Point clickPoint,
                           File mapFile) throws IOException
This function parses the requested mapfile a determines the URL associated with the clicked point.

The imagemap servlet recognizes standard NCSA mapfiles. In addition it recognizes the following enhancements:

Each line may be one of the following types: (the quoted descriptions are optional)
rect    URL left,top right,bottom "description"
circle  URL centerX,centerY edgePtX,edgePtY "description" 
poly    URL pt1X,pt1Y pt2X,pt2Y ... ptnX,ptnY "description"
default URL "description"
point   URL ptX,ptY "description"
text  "arbitrary marked-up text" 
base  map | referer | URL
#comment lines must begin with a #
Parameters:
req - the HTTP request
res - the HTTP response
clickPoint - the point the user clicked
mapFile - the mapFile that maps points to URLs
 o parsePoint
  protected static Point parsePoint(StreamTokenizer tokenStream) throws IOException, InvalidFileFormatException
Parses and returns a point from the input stream. The point must be in the form int,int
Parameters:
tokenStream - the stream to parse
Returns:
a point derieved from the next 3 token on the input stream
Throws: IOException
If an I/O error has occurred.
 o parseMenuText
  protected static String parseMenuText(StreamTokenizer tokenStream,
                                        URL url,
                                        String type,
                                        String menuText) throws IOException
Reads in the optional text that is display on text only browsers
Parameters:
tokenStream - the current StreamTokenizer
url - the url to insert in the menu
type - the type of mapfile entry, which will be desplayed by default if no optional text is provided
menuText - the menu text built up so far
Returns:
the menu text built up so far
 o pointInRect
  protected static boolean pointInRect(Point clickPoint,
                                       Point upperLeft,
                                       Point lowerRight)
Checks if the given point is within the bounds of the specified rectangle
Parameters:
clickPoint - the point clicked by the user
upperLeft - the upper left corner of the rectangle
lowerRight - the lower right corner of the rectangle
 o pointInCircle
  protected static boolean pointInCircle(Point clickPoint,
                                         Point center,
                                         Point edge)
Checks if the given point is within the bounds of the specified circle
Parameters:
clickPoint - the point clicked by the user
center - the center point of the circle
edge - any point on the edge of the circle
 o distanceSquared
  protected static int distanceSquared(Point point1,
                                       Point point2)
Calculates the square of the Euclidian distance between two points
Parameters:
point1 - the first point
point2 - the second point
 o pointInPoly
  protected static boolean pointInPoly(Point clickPoint,
                                       Vector points)
Checks if the given point is within the bounds of the specified polygon
Parameters:
clickPoint - the point clicked by the user
points - a vector of points describing the polygon
 o sendMenuResponse
  protected void sendMenuResponse(HttpServletResponse res,
                                  String menu) throws IOException
Responds with a textual menu of all available links in the mapfile
Parameters:
req - the HTTP response
menu - the text menu to display
Throws: IOException
If an I/O error has occurred.
 o sendErrorResponse
  protected void sendErrorResponse(HttpServletResponse res,
                                   String error) throws IOException
Returns an error message to the user if some error occured while processing the imagemap request
Parameters:
req - the HTTP response
error - a description of the error
Throws: IOException
If an I/O error has occurred.
 o sendResponse
  protected void sendResponse(HttpServletResponse res,
                              URL redirectURL) throws IOException
Returns a redirect response with the proper URL, or a "no content" response if no matching URL could be found
Parameters:
req - the HTTP response
redirectURL - the URL to redirect to
Throws: IOException
If an I/O error has occurred.
 o getServletInfo
  public String getServletInfo()
Returns information about the servlet
Overrides:
getServletInfo in class GenericServlet
 o main
  public static void main(String args[])

All Packages  Class Hierarchy  This Package  Previous  Next  Index