001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package org.apache.geronimo.samples.daytrader.web.prims; 018 019 import java.io.*; 020 import javax.servlet.*; 021 import javax.servlet.http.*; 022 023 import org.apache.geronimo.samples.daytrader.util.*; 024 025 026 /** 027 * 028 * PingServlet2JSP tests a call from a servlet to a JavaServer Page providing server-side dynamic 029 * HTML through JSP scripting. 030 * 031 */ 032 public class PingServlet2Jsp extends HttpServlet { 033 private static int hitCount = 0; 034 035 /** 036 * forwards post requests to the doGet method 037 * Creation date: (11/6/2000 10:52:39 AM) 038 * @param res javax.servlet.http.HttpServletRequest 039 * @param res2 javax.servlet.http.HttpServletResponse 040 */ 041 public void doPost(HttpServletRequest req, HttpServletResponse res) 042 throws ServletException, IOException { 043 doGet(req, res); 044 } 045 046 /** 047 * this is the main method of the servlet that will service all get requests. 048 * @param request HttpServletRequest 049 * @param responce HttpServletResponce 050 **/ 051 public void doGet(HttpServletRequest req, HttpServletResponse res) 052 throws ServletException, IOException { 053 PingBean ab; 054 try 055 { 056 ab = new PingBean(); 057 hitCount++; 058 ab.setMsg("Hit Count: " + hitCount); 059 req.setAttribute("ab", ab); 060 061 getServletConfig().getServletContext().getRequestDispatcher("/PingServlet2Jsp.jsp").forward(req, res); 062 } 063 catch (Exception ex) 064 { 065 Log.error( 066 ex,"PingServlet2Jsp.doGet(...): request error"); 067 res.sendError( 068 500, 069 "PingServlet2Jsp.doGet(...): request error" 070 + ex.toString()); 071 072 } 073 } 074 }