---- WICHTIG !!!!!! ---- WER ZU BLÖD IST DAS ZEUG GENUG ZU ÄNDERN UND DENKT ER KANN DAS 1 zu 1 ÜBERNEHMEN OHNE AUFZUFLIEGEN MUSS EXTREM SEHR BESCHEUERT SEIN (hallo tobi) UND SOLLTE ES EINFACH LASSEN. SONST KRIEG ICH WIEDER ÄRGER WORAUF ICH KEINEN BOCK HABE!!! ALSO -> ÄNDERN SONST TOD!!! P.S: Der folgende Source ist NICHT für tobi weil er einfach nur viel zu dumm is und denkt ernsthaft er kann das zeug unverändert abgeben... ich mein WIE DUMM KANN MAN SEIN TOBI!??!!?? Die Aufgaben 3 und 4 werden mit ProjektName/param (Aufgabe 3) bzw. ProjektName/firmen (Aufgabe 4) aufgerufen! ------- DATEI: Ausgabe.java ------- PACKAGE: servlet.tags package servlet.tags; import java.io.IOException; import javax.servlet.jsp.JspTagException; import javax.servlet.jsp.tagext.TagSupport; public class Ausgabe extends TagSupport { public int doStartTag() { return this.EVAL_PAGE; } public int doEndTag() throws JspTagException { try { pageContext.getOut().write("Viel Glück bei der MUK-Klausur!!!"); } catch(IOException e) { e.printStackTrace(); } return EVAL_PAGE; } } ------- DATEI ENDE ------- DATEI: Formular.java ------- PACKAGE: servlet.tags package servlet.tags; import java.io.IOException; import java.io.PrintWriter; import java.util.Enumeration; import java.util.Vector; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class Formular extends HttpServlet { Vector firmennamen = new Vector(); public void init() { Enumeration e = this.getInitParameterNames(); while(e.hasMoreElements()) { String firma = (String) e.nextElement(); String firmaValue = this.getInitParameter(firma); if(firmaValue != null) firmennamen.addElement(firmaValue); } } public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{ res.setContentType("text/html"); PrintWriter out = res.getWriter(); out.println("Aufgabe 4"); out.println(""); out.println("
"); out.println("

Firmenname

"); out.println(""); out.println("
"); out.println(""); } public void doPost (HttpServletRequest req, HttpServletResponse res)throws ServletException, IOException{ res.setContentType("text/html"); PrintWriter out = res.getWriter(); String eingabe = req.getParameter("firmenname"); out.println("Eingabe: "+eingabe+"
"); boolean hasFirmaGefunden = false; for(int i=0;i= 1 && parent.getCondition() <= 49)) { JspWriter out = pageContext.getOut(); try { out.println("Zahl "+parent.getCondition()+" ungültig!
"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else return this.SKIP_BODY; } } return this.SKIP_BODY; } public int doAfterBody() { return this.EVAL_BODY_INCLUDE; } } ------- DATEI ENDE ------- DATEI: IfTag.java ------- PACKAGE: servlet.tags package servlet.tags; import javax.servlet.jsp.tagext.BodyTagSupport; public class IfTag extends BodyTagSupport { private int condition; private boolean hasCondition = false; public int doStartTag() { return this.EVAL_BODY_INCLUDE; } public int doAfterBody() { return this.SKIP_BODY; } public boolean getHasCondition() { return hasCondition; } public int getCondition() { return condition; } public void setCondition(int condition) { hasCondition = true; this.condition = condition; } } ------- DATEI ENDE ------- DATEI: IfThenTag.java ------- PACKAGE: servlet.tags package servlet.tags; import java.io.IOException; import javax.servlet.jsp.JspWriter; import javax.servlet.jsp.tagext.BodyTagSupport; public class IfThenTag extends BodyTagSupport { public int doStartTag() { IfTag parent = (IfTag) this.findAncestorWithClass(this, IfTag.class); Lotto parentFromIf = (Lotto) parent.findAncestorWithClass(parent, Lotto.class); if(parent == null) { // Fehler } else { if(!parent.getHasCondition()) { // Fehler, keine Condition gesetzt } else { if(parent.getCondition() >= 1 && parent.getCondition() <= 49) { parentFromIf.setNeueZahl(parent.getCondition()); JspWriter out = pageContext.getOut(); try { out.println("Zahl "+parent.getCondition()+" gültig!
"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else return this.SKIP_BODY; } } return this.SKIP_BODY; } public int doAfterBody() { return this.EVAL_BODY_INCLUDE; } } ------- DATEI ENDE ------- DATEI: Lotto.java ------- PACKAGE: servlet.tags package servlet.tags; import java.io.IOException; import java.util.Vector; import javax.servlet.jsp.JspWriter; import javax.servlet.jsp.tagext.BodyTagSupport; public class Lotto extends BodyTagSupport { boolean repeat = true; Vector zahlen = new Vector(); public int doStartTag() { return this.EVAL_BODY_INCLUDE; } public void setNeueZahl(int zahl) { zahlen.addElement(zahl); if(zahlen.size()>= 6) repeat = false; } public int doAfterBody() { if(repeat) return this.EVAL_BODY_AGAIN; else { JspWriter out = pageContext.getOut(); try { out.println("

Gefundene Zahlen:

"); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } for(int i=0;i"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return this.SKIP_BODY; } } } ------- DATEI ENDE ------- DATEI: Param.java ------- PACKAGE: servlet.tags package servlet.tags; import java.io.IOException; import java.io.PrintWriter; import java.util.Enumeration; import java.util.Vector; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class Param extends HttpServlet { Vector initParameterValue = new Vector(); Vector initParameterNames = new Vector(); public void init() throws ServletException { Enumeration e = this.getInitParameterNames(); while(e.hasMoreElements()) { String initParam = (String) e.nextElement(); String initParamValue = this.getInitParameter(initParam); if(initParamValue != null) { initParameterValue.addElement(initParamValue); initParameterNames.addElement(initParam); } } } public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); PrintWriter out = res.getWriter(); for(int i=0;i"); } } } ------- DATEI ENDE ------- DATEI: taglib.tld ------- PFAD: WEB-INF/lib 1.0 1.1 mybib OReilly Sample Tag library Ausgabe servlet.tags.Ausgabe Klausur 3 - Aufgabe 1 JSP Lotto servlet.tags.Lotto Klausur 3 - Aufgabe 2 JSP MyFont servlet.tags.MyFont MyFont-Tag JSP font true if servlet.tags.IfTag If-Tag JSP condition servlet.tags.IfConditionTag If-Condition-Tag JSP then servlet.tags.IfThenTag If-Then-Tag JSP else servlet.tags.IfElseTag If-Else-Tag JSP repeat servlet.tags.RepeatTag If-Condition-Tag JSP reps true ------- DATEI ENDE ------- DATEI: web.xml ------- PFAD: WEB-INF http://xmlguru.de/jct /WEB-INF/tags.tld firmen servlet.tags.Formular Firma1 ADV Firma2 BDV Firma3 CDV firmen /firmen param servlet.tags.Param Firmenname ADV Firmenbezeichnung Softwareentwickler Firmenvorsitzender Michael Bessert param /param ------- DATEI ENDE ------- DATEI: aufgabe1.jsp ------- PFAD: / Test <%@ taglib uri="WEB-INF/lib/taglib.tld" prefix="mybib" %> ------- DATEI ENDE ------- DATEI: aufgabe2.jsp ------- PFAD: / Test 2 <%@ taglib uri="WEB-INF/lib/taglib.tld" prefix="mybib" %> <%= (int)(Math.random() * 100) %> ------- DATEI ENDE