Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 package org.apache.geronimo.samples.daytrader.web.prims.ejb3;
 import  javax.servlet.*;
 import  javax.servlet.http.*;
 import javax.naming.*;
 import  javax.ejb.EJB;
 // TODO: fix comments
PingServlet2Session2JDBC tests key functionality of a servlet call to a stateless SessionEJB, and then to a Entity EJB representing data in a database. This servlet makes use of the Stateless Session EJB Trade, and then uses TradeConfig to generate a random stock symbol. The stocks price is looked up using the Quote Entity EJB.
 public class PingServlet2Session2JDBC extends HttpServlet {
     private static String initTime;
     private static int hitCount;
     public void doPost(HttpServletRequest req, HttpServletResponse resthrows ServletException, IOException {
     public void doGet(HttpServletRequest req, HttpServletResponse resthrows IOException, ServletException {
         res.setContentType("text/html"); out = res.getWriter();
         String symbol = null;
         QuoteDataBean quoteData = null;
         StringBuffer output = new StringBuffer(100);
         output.append("<html><head><title>PingServlet2Session2JDBC</title></head>" + "<body><HR><FONT size=\"+2\" color=\"#000066\">PingServlet2Session2JDBC<BR></FONT>" + "<FONT size=\"-1\" color=\"#000066\">" + "PingServlet2Session2JDBC tests the common path of a Servlet calling a Session EJB "
                 + "which in turn calls JDBC.<BR>");
         try {
             try {
                 int iter = TradeConfig.getPrimIterations();
                 for (int ii = 0; ii < iterii++) {
                     symbol = TradeConfig.rndSymbol();
                     // getQuote will call findQuote which will instaniate the
                     // Quote Entity Bean
                     // and then will return a QuoteObject
                     quoteData = .getQuote(symbol);
             } catch (Exception ne) {
                 Log.error(ne"PingServlet2Session2JDBC.goGet(...): exception getting QuoteData through Trade");
                 throw ne;
             output.append("<HR>initTime: " + ).append("<BR>Hit Count: " + ++);
             output.append("<HR>Quote Information<BR><BR>" + quoteData.toHTML());
         } catch (Exception e) {
             Log.error(e"PingServlet2Session2JDBC.doGet(...): General Exception caught");
             res.sendError(500, "General Exception caught, " + e.toString());
     public String getServletInfo() {
         return "web primitive, tests Servlet to Session to Entity EJB path";
     public void init(ServletConfig configthrows ServletException {
          = 0;
         = new java.util.Date().toString();
New to GrepCode? Check out our FAQ X