geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r562310 - in /geronimo/samples/trunk/samples/jaxws-calculator/jaxws-calculator-war/src/main/webapp: add.jsp addResult.jsp
Date Fri, 03 Aug 2007 01:52:03 GMT
Author: gawor
Date: Thu Aug  2 18:52:02 2007
New Revision: 562310

URL: http://svn.apache.org/viewvc?view=rev&rev=562310
Log:
show results on the same page

Removed:
    geronimo/samples/trunk/samples/jaxws-calculator/jaxws-calculator-war/src/main/webapp/addResult.jsp
Modified:
    geronimo/samples/trunk/samples/jaxws-calculator/jaxws-calculator-war/src/main/webapp/add.jsp

Modified: geronimo/samples/trunk/samples/jaxws-calculator/jaxws-calculator-war/src/main/webapp/add.jsp
URL: http://svn.apache.org/viewvc/geronimo/samples/trunk/samples/jaxws-calculator/jaxws-calculator-war/src/main/webapp/add.jsp?view=diff&rev=562310&r1=562309&r2=562310
==============================================================================
--- geronimo/samples/trunk/samples/jaxws-calculator/jaxws-calculator-war/src/main/webapp/add.jsp
(original)
+++ geronimo/samples/trunk/samples/jaxws-calculator/jaxws-calculator-war/src/main/webapp/add.jsp
Thu Aug  2 18:52:02 2007
@@ -16,7 +16,7 @@
 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
class="cell"">
 <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
-<%@ page import="java.net.URL,javax.xml.namespace.QName,javax.xml.ws.Service,org.apache.geronimo.samples.jws.Calculator"%>
+<%@ page import="javax.naming.InitialContext,javax.xml.ws.Service,org.apache.geronimo.samples.jws.Calculator"%>
 <html  xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
 <head>
   <title>Apache Geronimo Sample Application - JAX-WS Calculator</title>
@@ -27,10 +27,38 @@
   <font face="Verdana, Helvetica, Arial">
 
     <h3>This is a JAX-WS web service sample application.   Please type the value 1
and value 2 below to see the add result.</h3>
-    <form action="addResult.jsp">
-        Input 1: <input type="text" name="value1"> + Input 2: <input type="text"
name="value2"> <input type="submit" value="=">
+    <form action="add.jsp">
+        Value 1: <input type="text" name="value1">   Value 2: <input type="text"
name="value2"> <input type="submit" value="Add">
     </form>
+    <br>
+<%
+    String value1 = request.getParameter( "value1" );
+    String value2 = request.getParameter( "value2" );
 
+    System.out.println(value1 + " " + value2);
+
+    if (value1 != null && value1.trim().length() > 0 &&
+        value2 != null && value2.trim().length() > 0) {
+
+        out.println("<h4>");
+
+        try {
+            int v1 = Integer.parseInt(value1);
+            int v2 = Integer.parseInt(value2);
+    
+            InitialContext ctx = new InitialContext();
+            Service service = (Service)ctx.lookup("java:comp/env/services/Calculator");
+            Calculator calc = service.getPort(Calculator.class);         
+            int sum = calc.add(v1, v2);
+            out.println("Result: " + v1 + " + " + v2 + " = " + sum);
+        } catch ( Exception e ) {
+            e.printStackTrace();
+            out.println("Error: " + e.getMessage());
+       }
+
+       out.println("</h4>");
+    }
+%>
 
   </FONT>
 </body>



Mime
View raw message