01: /**
02: * $Id: ParmTag.java,v 1.2 2002/06/01 22:16:17 sorensen Exp $
03: * Copyright 2002 Sun Microsystems, Inc. All
04: * rights reserved. Use of this product is subject
05: * to license terms. Federal Acquisitions:
06: * Commercial Software -- Government Users
07: * Subject to Standard License Terms and
08: * Conditions.
09: *
10: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
11: * are trademarks or registered trademarks of Sun Microsystems,
12: * Inc. in the United States and other countries.
13: */package com.sun.portal.wireless.taglibs.util;
14:
15: import javax.servlet.jsp.*;
16: import javax.servlet.jsp.tagext.*;
17: import java.io.*;
18: import javax.servlet.*;
19: import javax.servlet.http.*;
20:
21: import com.sun.portal.wireless.taglibs.base.*;
22:
23: /**
24: * <util:parm> tag implementation.
25: *
26: *
27: * @author John Saare
28: * @version 1.0, 03/08/2001
29: */
30: public class ParmTag extends BaseBodyTagSupport {
31:
32: private String parmName = null;
33: private UrlMaker parent;
34: private boolean rfc2396 = true;
35: private boolean urlAmpEntity = true;
36:
37: /**
38: * Called at the beginning of a tag...
39: *
40: * @return what to do next
41: */
42: public int doStartTag() throws JspTagException {
43: UtilContext context;
44:
45: try {
46: context = UtilContext.getContext(pageContext);
47: rfc2396 = context.getRfc2396();
48: urlAmpEntity = context.getUrlAmpEntity();
49: } catch (Exception e) {
50: // Ignore...
51: }
52:
53: parent = (UrlMaker) findAncestorWithClass(this , UrlMaker.class);
54: if (parent == null) {
55: throw new JspTagException(
56: "\"parm\" tag only valid in \"url|forward|include\" tag body.");
57: }
58: return (EVAL_BODY_TAG);
59: }
60:
61: /**
62: * Adds a parm to the URL under construction,
63: * and performs HTTP URI escaping.
64: *
65: * @return what to do next
66: */
67: public int doAfterBody() {
68: BodyContent body = getBodyContent();
69: if (rfc2396) {
70: parent.addParm(parmName, Util.rfc2396Escape(pageContext,
71: body.getString()), urlAmpEntity);
72: } else {
73: parent.addParm(parmName, body.getString(), urlAmpEntity);
74: }
75: body.clearBody();
76:
77: return (SKIP_BODY);
78: }
79:
80: /**
81: * "name" attribute set method...
82: *
83: * @param s attribute value.
84: */
85: public void setName(String s) {
86: parmName = Util.evalAttribute(pageContext, s);
87: }
88:
89: }
|