KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ajaxtags > servlets > AjaxActionHelper


1 /**
2  * Copyright (C) 2007 Jens Kapitza
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.ajaxtags.servlets;
17
18 import javax.servlet.http.HttpServletRequest JavaDoc;
19 import javax.servlet.http.HttpServletResponse JavaDoc;
20
21
22 /**
23  *
24  * @author Jens Kapitza
25  *
26  */

27 public class AjaxActionHelper {
28     /**
29      *
30      * Invoke the ajax action and setup the request and response
31      *
32      * @param action
33      * the ajaxaction implementation
34      * @param request
35      * the request
36      * @param response
37      * the response
38      * @return the xml content from action
39      * @throws Exception
40      */

41     static public String JavaDoc invoke(BaseAjaxXmlAction action,
42             HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
43             throws Exception JavaDoc {
44         // prepare CALL
45
request.setCharacterEncoding("UTF-8");
46         // Set content to xml
47
response.setContentType("text/xml; charset=UTF-8");
48         // Set standard HTTP/1.1 no-cache headers.
49
response.setHeader("Cache-Control",
50                 "no-store, max-age=0, no-cache, must-revalidate");
51
52         // Set IE extended HTTP/1.1 no-cache headers.
53
response.addHeader("Cache-Control", "post-check=0, pre-check=0");
54
55         // Set standard HTTP/1.0 no-cache header.
56
response.setHeader("Pragma", "no-cache");
57
58         // no cahe
59

60         return action.getXmlContent(request, response);
61     }
62 }
63
Popular Tags