1 / 13

EAP Aufgabe 4.2

EAP Aufgabe 4.2. PEA 07. Tosten Nordmann Christian Jordan Jens Frommelt. Was will ich eigentlich sagen. Security ist doof CMP JSP Frage: Wohin mit der Anwendungslogik?. EJB Container. RequestInputBean. CMP. WEB Container. JSP. DB. RequestInputBean. gewuerzname propertyStatusMsg

saman
Download Presentation

EAP Aufgabe 4.2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. EAP Aufgabe 4.2 PEA 07 Tosten Nordmann Christian Jordan Jens Frommelt

  2. Was will ich eigentlich sagen • Security ist doof • CMP • JSP • Frage: Wohin mit der Anwendungslogik?

  3. EJB Container RequestInputBean CMP WEB Container JSP DB

  4. RequestInputBean • gewuerzname • propertyStatusMsg • isInitilized • Getter-/Setter-Methoden • isValid()

  5. Spicerequest.jsp Inputvalidate.jsp WSRequest.jsp

  6. Spicerequest.jsp <%-- Verweis auf ein Value-Bean, in dem die Benutzereingaben gesichert und validiert werden --%> <jsp:useBean id="requestInput" scope="request" class="pea07.beans.RequestInputBean" /> <h3>Statusmeldungen:</h3> <%-- Ausgabeliste mit inkorrekten Werten, falls vorhanden --%> <%-- Hier wird ebenfalls eine Bean-Property aus RequestInputBean abgefragt --%> <font color="red"> <jsp:getProperty name="requestInput" property="propertyStatusMsg" /> </font> <form action="inputvalidate.jsp" method="post"> <table border="1"> <tr> <td>Gewuerzname:</td> <td><input type="text" name="gewuerzname" value="" > <%-- ‘Eingabefeld‘ --%> </td> </tr> <tr> <td colspan=2><input type="submit" value="Als WS suchen"></td> <%-- 'Anfrage senden' Button --%> </tr> </table> </form>

  7. Inputvalidate.jsp <jsp:useBean id="requestInput" scope="request" class="pea07.beans.RequestInputBean" > <jsp:setProperty name="requestInput" property="*" /> </jsp:useBean> <% if (requestInput.isValid()) { %> <jsp:forward page="WSRequest.jsp" /> <% } else { %> <jsp:forward page="spicerequest.jsp" /> <% } %>

  8. WSRequest.jsp <% //Instanz eines ServiceLocators erzeugen, die den WebService ausfindig macht Pea07_SpiceWSServiceLocator locator = new Pea07_SpiceWSServiceLocator(); //Web-Service initialisieren Pea07_SpiceWS service = null; try { //Service erzeugen service = locator.getPea07_SpiceWS(new URL( "http://localhost:80/jboss-net/services/Pea07_SpiceWS")); } catch (javax.xml.rpc.ServiceException se) { out.println("Service-Fehler: "+se.toString()); } catch (MalformedURLException mue) { out.println("URL-Ausnahme: "+mue.toString()); }

  9. WSRequest.jsp (2) //Service verwenden, Suche durchführen //Service verwenden, finde alle Gewürze des Lagerbestands Pea07_Gewuerz spice = null; Pea07_Gewuerz[] spices = null; try { spice = service.pea07_searchSpice(requestInput.getGewuerzname()); spices = service.pea07_searchAllSpices(); } catch (java.rmi.RemoteException re) { out.println("Es wurde eine RemoteException geworfen: "); re.printStackTrace(System.out); } out.println("Spice Name: "+spice.getName()+"<br>"); out.println("Spice Price: "+spice.getPreis()+"<br>"); out.println("Amount in storage [kg]: "+spice.getMenge()+"<br>"); out.println("<br><br>"); out.println("<h3>List of all offered spices</h3><br>"); for (int k=0; k < spices.length; k++) { out.println(k+1+". "+spices[k].getName()); } %>

  10. Fröhliche Weihnachten!

More Related