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
-
ImagemapServlet()
- Creates a new imagemap servlet.
-
distanceSquared(Point, Point)
- Calculates the square of the Euclidian distance between
two points
-
getServletInfo()
- Returns information about the servlet
-
main(String[])
-
-
parseMapFile(HttpServletRequest, HttpServletResponse, Point, File)
- This function parses the requested mapfile a determines the URL
associated with the clicked point.
-
parseMenuText(StreamTokenizer, URL, String, String)
- Reads in the optional text that is display on text only browsers
-
parsePoint(StreamTokenizer)
- Parses and returns a point from the input stream.
-
pointInCircle(Point, Point, Point)
- Checks if the given point is within the bounds
of the specified circle
-
pointInPoly(Point, Vector)
- Checks if the given point is within the bounds
of the specified polygon
-
pointInRect(Point, Point, Point)
- Checks if the given point is within the bounds
of the specified rectangle
-
sendErrorResponse(HttpServletResponse, String)
- Returns an error message to the user if some error
occured while processing the imagemap request
-
sendMenuResponse(HttpServletResponse, String)
- Responds with a textual menu of all available links in the
mapfile
-
sendResponse(HttpServletResponse, URL)
- Returns a redirect response with the proper URL, or
a "no content" response if no matching URL could be found
-
service(HttpServletRequest, HttpServletResponse)
- Services a single imagemap request from the client.
ImagemapServlet
public ImagemapServlet()
- Creates a new imagemap servlet.
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
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:
- Lines of type
rect
, circle
,
point
, poly
, and default
may have an optional quoted string at the end of the line which
is desplayed in the menu generated for text only browsers.
- A line of type
text
consisting of the
text
keyword and a quoted string will cause the
quoted text (which may contain HTML markup) to appear
in the menu generated for text only browsers in the order it
appears in the mapfile.
- A line of type
base
can be used to specify
a different base URL for any relative URLs that appear in the
mapfile after the base line. The options are:
base map
- The URL of the mapfile is used as the base URL.
base referer
- The URL of the document containing the imagemap is
used as the base URL.
base URL
- The full URL given is used as the base URL.
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
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.
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
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
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
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
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
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.
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.
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.
getServletInfo
public String getServletInfo()
- Returns information about the servlet
- Overrides:
- getServletInfo in class GenericServlet
main
public static void main(String args[])
All Packages Class Hierarchy This Package Previous Next Index