Chinaunix首页 | 论坛 | 博客
  • 博客访问: 754249
  • 博文数量: 771
  • 博客积分: 6000
  • 博客等级: 准将
  • 技术积分: 5005
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-11 14:24
文章分类

全部博文(771)

文章存档

2011年(1)

2008年(770)

我的朋友

分类:

2008-09-11 14:31:58

 

tooTip.html:


 
    Ajax Tooltip
   
 
 
   

Ajax Tooltip Example


   

Golf Courses


   
       
           
           
           
           
               
   
Augusta National
Pinehurst No. 2
St. Andrews Links
Baltusrol Golf Club

   

 

 

ToolTipServlet.java:

/*
 * ToolTipServlet.java
 *
 * Created on June 30, 2005, 8:29 PM
 */

package ajaxbook.chap4;

import java.io.*;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.*;
import javax.servlet.http.*;

/**
 *
 * @author nate
 * @version
 */
public class ToolTipServlet extends HttpServlet {
   
    private Map courses = new HashMap();

    public void init(ServletConfig config) throws ServletException {
        CourseData augusta = new CourseData(72, 7290);
        CourseData pinehurst = new CourseData(70, 7214);
        CourseData standrews = new CourseData(72, 6566);
        CourseData baltusrol = new CourseData(70, 7392);
        courses.put(new Integer(1), augusta);
        courses.put(new Integer(2), pinehurst);
        courses.put(new Integer(3), standrews);
        courses.put(new Integer(4), baltusrol);
    }
   
    /** Handles the HTTP GET method.
     * @param request servlet request
     * @param response servlet response
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        Integer key = Integer.valueOf(request.getParameter("key"));
        CourseData data = (CourseData) courses.get(key);
       
        PrintWriter out = response.getWriter();

        response.setContentType("text/xml");
        response.setHeader("Cache-Control", "no-cache");

        out.println("");
        out.println("" + data.getPar() + "");
        out.println("" + data.getLength() + "");
        out.println("
");
        out.close();
    }
   
    /** Handles the HTTP POST method.
     * @param request servlet request
     * @param response servlet response
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        doGet(request, response);
    }
       
    /** Returns a short description of the servlet.
     */
    public String getServletInfo() {
        return "Short description";
    }
   
    private class CourseData {
        private int par;
        private int length;
       
        public CourseData(int par, int length) {
            this.par = par;
            this.length = length;
        }
       
        public int getPar() {
            return this.par;
        }
       
        public int getLength() {
            return this.length;
        }
    }
}

 


--------------------next---------------------

阅读(471) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~