init
This commit is contained in:
90
java/javax/servlet/jsp/ErrorData.java
Normal file
90
java/javax/servlet/jsp/ErrorData.java
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp;
|
||||
|
||||
/**
|
||||
* Contains information about an error, for error pages. The information
|
||||
* contained in this instance is meaningless if not used in the context of an
|
||||
* error page. To indicate a JSP is an error page, the page author must set the
|
||||
* isErrorPage attribute of the page directive to "true".
|
||||
*
|
||||
* @see PageContext#getErrorData
|
||||
* @since 2.0
|
||||
*/
|
||||
public final class ErrorData {
|
||||
|
||||
private final Throwable throwable;
|
||||
private final int statusCode;
|
||||
private final String uri;
|
||||
private final String servletName;
|
||||
|
||||
/**
|
||||
* Creates a new ErrorData object.
|
||||
*
|
||||
* @param throwable
|
||||
* The Throwable that is the cause of the error
|
||||
* @param statusCode
|
||||
* The status code of the error
|
||||
* @param uri
|
||||
* The request URI
|
||||
* @param servletName
|
||||
* The name of the servlet invoked
|
||||
*/
|
||||
public ErrorData(Throwable throwable, int statusCode, String uri,
|
||||
String servletName) {
|
||||
this.throwable = throwable;
|
||||
this.statusCode = statusCode;
|
||||
this.uri = uri;
|
||||
this.servletName = servletName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Throwable that caused the error.
|
||||
*
|
||||
* @return The Throwable that caused the error
|
||||
*/
|
||||
public Throwable getThrowable() {
|
||||
return this.throwable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the status code of the error.
|
||||
*
|
||||
* @return The status code of the error
|
||||
*/
|
||||
public int getStatusCode() {
|
||||
return this.statusCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the request URI.
|
||||
*
|
||||
* @return The request URI
|
||||
*/
|
||||
public String getRequestURI() {
|
||||
return this.uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the servlet invoked.
|
||||
*
|
||||
* @return The name of the servlet invoked
|
||||
*/
|
||||
public String getServletName() {
|
||||
return this.servletName;
|
||||
}
|
||||
}
|
||||
60
java/javax/servlet/jsp/HttpJspPage.java
Normal file
60
java/javax/servlet/jsp/HttpJspPage.java
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* The HttpJspPage interface describes the interaction that a JSP Page
|
||||
* Implementation Class must satisfy when using the HTTP protocol.
|
||||
*
|
||||
* <p>
|
||||
* The behaviour is identical to that of the JspPage, except for the signature
|
||||
* of the _jspService method, which is now expressible in the Java type
|
||||
* system and included explicitly in the interface.
|
||||
*
|
||||
* @see JspPage
|
||||
*/
|
||||
|
||||
public interface HttpJspPage extends JspPage {
|
||||
|
||||
/** The _jspService()method corresponds to the body of the JSP page. This
|
||||
* method is defined automatically by the JSP container and should never
|
||||
* be defined by the JSP page author.
|
||||
* <p>
|
||||
* If a superclass is specified using the extends attribute, that
|
||||
* superclass may choose to perform some actions in its service() method
|
||||
* before or after calling the _jspService() method. See using the extends
|
||||
* attribute in the JSP_Engine chapter of the JSP specification.
|
||||
*
|
||||
* @param request Provides client request information to the JSP.
|
||||
* @param response Assists the JSP in sending a response to the client.
|
||||
* @throws ServletException Thrown if an error occurred during the
|
||||
* processing of the JSP and that the container should take
|
||||
* appropriate action to clean up the request.
|
||||
* @throws IOException Thrown if an error occurred while writing the
|
||||
* response for this page.
|
||||
*/
|
||||
public void _jspService(HttpServletRequest request,
|
||||
HttpServletResponse response)
|
||||
throws ServletException, IOException;
|
||||
}
|
||||
80
java/javax/servlet/jsp/JspApplicationContext.java
Normal file
80
java/javax/servlet/jsp/JspApplicationContext.java
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp;
|
||||
|
||||
import javax.el.ELContextListener;
|
||||
import javax.el.ELResolver;
|
||||
import javax.el.ExpressionFactory;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Stores <i>application</i>-scoped information for the JSP container.
|
||||
* </p>
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public interface JspApplicationContext {
|
||||
|
||||
/**
|
||||
* Registers an <code>ELContextListener</code> that will be notified
|
||||
* whenever a new <code>ELContext</code> is created.
|
||||
* <p>
|
||||
* At the very least, any <code>ELContext</code> instantiated will have
|
||||
* reference to the <code>JspContext</code> under
|
||||
* <code>JspContext.class</code>.
|
||||
*
|
||||
* @param listener The listener to add
|
||||
*/
|
||||
public void addELContextListener(ELContextListener listener);
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Adds an <code>ELResolver</code> to the chain of EL variable and property
|
||||
* management within JSP pages and Tag files.
|
||||
* </p>
|
||||
* <p>
|
||||
* JSP has a default set of ELResolvers to chain for all EL evaluation:
|
||||
* </p>
|
||||
* <ul>
|
||||
* <li><code>ImplicitObjectELResolver</code></li>
|
||||
* <li><code>ELResolver</code> instances registered with this method</li>
|
||||
* <li><code>MapELResolver</code></li>
|
||||
* <li><code>ListELResolver</code></li>
|
||||
* <li><code>ArrayELResolver</code></li>
|
||||
* <li><code>BeanELResolver</code></li>
|
||||
* <li><code>ScopedAttributeELResolver</code></li>
|
||||
* </ul>
|
||||
*
|
||||
* @param resolver
|
||||
* an additional resolver
|
||||
* @throws IllegalStateException
|
||||
* if called after the application's
|
||||
* <code>ServletContextListeners</code> have been initialized.
|
||||
*/
|
||||
public void addELResolver(ELResolver resolver) throws IllegalStateException;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Returns the JSP container's <code>ExpressionFactory</code> implementation
|
||||
* for EL use.
|
||||
* </p>
|
||||
*
|
||||
* @return an <code>ExpressionFactory</code> implementation
|
||||
*/
|
||||
public ExpressionFactory getExpressionFactory();
|
||||
|
||||
}
|
||||
282
java/javax/servlet/jsp/JspContext.java
Normal file
282
java/javax/servlet/jsp/JspContext.java
Normal file
@@ -0,0 +1,282 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp;
|
||||
|
||||
import java.util.Enumeration;
|
||||
|
||||
import javax.el.ELContext;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* <code>JspContext</code> serves as the base class for the
|
||||
* PageContext class and abstracts all information that is not specific
|
||||
* to servlets. This allows for Simple Tag Extensions to be used
|
||||
* outside of the context of a request/response Servlet.
|
||||
* <p>
|
||||
* The JspContext provides a number of facilities to the
|
||||
* page/component author and page implementor, including:
|
||||
* <ul>
|
||||
* <li>a single API to manage the various scoped namespaces
|
||||
* <li>a mechanism to obtain the JspWriter for output
|
||||
* <li>a mechanism to expose page directive attributes to the
|
||||
* scripting environment
|
||||
* </ul>
|
||||
*
|
||||
* <p><B>Methods Intended for Container Generated Code</B>
|
||||
* <p>
|
||||
* The following methods enable the <B>management of nested</B> JspWriter
|
||||
* streams to implement Tag Extensions: <code>pushBody()</code> and
|
||||
* <code>popBody()</code>
|
||||
*
|
||||
* <p><B>Methods Intended for JSP authors</B>
|
||||
* <p>
|
||||
* Some methods provide <B>uniform access</B> to the diverse objects
|
||||
* representing scopes.
|
||||
* The implementation must use the underlying machinery
|
||||
* corresponding to that scope, so information can be passed back and
|
||||
* forth between the underlying environment (e.g. Servlets) and JSP pages.
|
||||
* The methods are:
|
||||
* <code>setAttribute()</code>, <code>getAttribute()</code>,
|
||||
* <code>findAttribute()</code>, <code>removeAttribute()</code>,
|
||||
* <code>getAttributesScope()</code> and
|
||||
* <code>getAttributeNamesInScope()</code>.
|
||||
*
|
||||
* <p>
|
||||
* The following methods provide <B>convenient access</B> to implicit objects:
|
||||
* <code>getOut()</code>
|
||||
*
|
||||
* <p>
|
||||
* The following methods provide <B>programmatic access</b> to the
|
||||
* Expression Language evaluator:
|
||||
* <code>getExpressionEvaluator()</code>, <code>getVariableResolver()</code>
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
|
||||
public abstract class JspContext {
|
||||
|
||||
/**
|
||||
* Sole constructor. (For invocation by subclass constructors,
|
||||
* typically implicit.)
|
||||
*/
|
||||
public JspContext() {
|
||||
// NOOP by default
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the name and value specified with page scope semantics.
|
||||
* If the value passed in is <code>null</code>, this has the same
|
||||
* effect as calling
|
||||
* <code>removeAttribute( name, PageContext.PAGE_SCOPE )</code>.
|
||||
*
|
||||
* @param name the name of the attribute to set
|
||||
* @param value the value to associate with the name, or null if the
|
||||
* attribute is to be removed from the page scope.
|
||||
* @throws NullPointerException if the name is null
|
||||
*/
|
||||
|
||||
public abstract void setAttribute(String name, Object value);
|
||||
|
||||
/**
|
||||
* Register the name and value specified with appropriate
|
||||
* scope semantics. If the value passed in is <code>null</code>,
|
||||
* this has the same effect as calling
|
||||
* <code>removeAttribute( name, scope )</code>.
|
||||
*
|
||||
* @param name the name of the attribute to set
|
||||
* @param value the object to associate with the name, or null if
|
||||
* the attribute is to be removed from the specified scope.
|
||||
* @param scope the scope with which to associate the name/object
|
||||
*
|
||||
* @throws NullPointerException if the name is null
|
||||
* @throws IllegalArgumentException if the scope is invalid
|
||||
* @throws IllegalStateException if the scope is
|
||||
* PageContext.SESSION_SCOPE but the page that was requested
|
||||
* does not participate in a session or the session has been
|
||||
* invalidated.
|
||||
*/
|
||||
|
||||
public abstract void setAttribute(String name, Object value, int scope);
|
||||
|
||||
/**
|
||||
* Returns the object associated with the name in the page scope or null
|
||||
* if not found.
|
||||
*
|
||||
* @param name the name of the attribute to get
|
||||
* @return the object associated with the name in the page scope
|
||||
* or null if not found.
|
||||
*
|
||||
* @throws NullPointerException if the name is null
|
||||
*/
|
||||
|
||||
public abstract Object getAttribute(String name);
|
||||
|
||||
/**
|
||||
* Return the object associated with the name in the specified
|
||||
* scope or null if not found.
|
||||
*
|
||||
* @param name the name of the attribute to set
|
||||
* @param scope the scope with which to associate the name/object
|
||||
* @return the object associated with the name in the specified
|
||||
* scope or null if not found.
|
||||
*
|
||||
* @throws NullPointerException if the name is null
|
||||
* @throws IllegalArgumentException if the scope is invalid
|
||||
* @throws IllegalStateException if the scope is
|
||||
* PageContext.SESSION_SCOPE but the page that was requested
|
||||
* does not participate in a session or the session has been
|
||||
* invalidated.
|
||||
*/
|
||||
|
||||
public abstract Object getAttribute(String name, int scope);
|
||||
|
||||
/**
|
||||
* Searches for the named attribute in page, request, session (if valid),
|
||||
* and application scope(s) in order and returns the value associated or
|
||||
* null.
|
||||
*
|
||||
* @param name the name of the attribute to search for
|
||||
* @return the value associated or null
|
||||
* @throws NullPointerException if the name is null
|
||||
*/
|
||||
|
||||
public abstract Object findAttribute(String name);
|
||||
|
||||
/**
|
||||
* Remove the object reference associated with the given name
|
||||
* from all scopes. Does nothing if there is no such object.
|
||||
*
|
||||
* @param name The name of the object to remove.
|
||||
* @throws NullPointerException if the name is null
|
||||
*/
|
||||
|
||||
public abstract void removeAttribute(String name);
|
||||
|
||||
/**
|
||||
* Remove the object reference associated with the specified name
|
||||
* in the given scope. Does nothing if there is no such object.
|
||||
*
|
||||
* @param name The name of the object to remove.
|
||||
* @param scope The scope where to look.
|
||||
* @throws IllegalArgumentException if the scope is invalid
|
||||
* @throws IllegalStateException if the scope is
|
||||
* PageContext.SESSION_SCOPE but the page that was requested
|
||||
* does not participate in a session or the session has been
|
||||
* invalidated.
|
||||
* @throws NullPointerException if the name is null
|
||||
*/
|
||||
|
||||
public abstract void removeAttribute(String name, int scope);
|
||||
|
||||
/**
|
||||
* Get the scope where a given attribute is defined.
|
||||
*
|
||||
* @param name the name of the attribute to return the scope for
|
||||
* @return the scope of the object associated with the name specified or 0
|
||||
* @throws NullPointerException if the name is null
|
||||
*/
|
||||
|
||||
public abstract int getAttributesScope(String name);
|
||||
|
||||
/**
|
||||
* Enumerate all the attributes in a given scope.
|
||||
*
|
||||
* @param scope the scope to enumerate all the attributes for
|
||||
* @return an enumeration of names (java.lang.String) of all the
|
||||
* attributes the specified scope
|
||||
* @throws IllegalArgumentException if the scope is invalid
|
||||
* @throws IllegalStateException if the scope is
|
||||
* PageContext.SESSION_SCOPE but the page that was requested
|
||||
* does not participate in a session or the session has been
|
||||
* invalidated.
|
||||
*/
|
||||
|
||||
public abstract Enumeration<String> getAttributeNamesInScope(int scope);
|
||||
|
||||
/**
|
||||
* The current value of the out object (a JspWriter).
|
||||
*
|
||||
* @return the current JspWriter stream being used for client response
|
||||
*/
|
||||
public abstract JspWriter getOut();
|
||||
|
||||
/**
|
||||
* Provides programmatic access to the ExpressionEvaluator.
|
||||
* The JSP Container must return a valid instance of an
|
||||
* ExpressionEvaluator that can parse EL expressions.
|
||||
*
|
||||
* @return A valid instance of an ExpressionEvaluator.
|
||||
* @since 2.0
|
||||
* @deprecated As of JSP 2.1, replaced by
|
||||
* JspApplicationContext.getExpressionFactory()
|
||||
*/
|
||||
@SuppressWarnings("dep-ann") // TCK signature test fails with annotation
|
||||
public abstract javax.servlet.jsp.el.ExpressionEvaluator getExpressionEvaluator();
|
||||
|
||||
|
||||
public abstract ELContext getELContext();
|
||||
|
||||
/**
|
||||
* Returns an instance of a VariableResolver that provides access to the
|
||||
* implicit objects specified in the JSP specification using this JspContext
|
||||
* as the context object.
|
||||
*
|
||||
* @return A valid instance of a VariableResolver.
|
||||
* @since 2.0
|
||||
* @deprecated As of JSP 2.1,
|
||||
* replaced by javax.el.ELContext.getELResolver()
|
||||
* which can be obtained by
|
||||
* jspContext.getELContext().getELResolver()
|
||||
*/
|
||||
@SuppressWarnings("dep-ann") // TCK signature test fails with annotation
|
||||
public abstract javax.servlet.jsp.el.VariableResolver getVariableResolver();
|
||||
|
||||
/**
|
||||
* Return a new JspWriter object that sends output to the
|
||||
* provided Writer. Saves the current "out" JspWriter,
|
||||
* and updates the value of the "out" attribute in the
|
||||
* page scope attribute namespace of the JspContext.
|
||||
* <p>The returned JspWriter must implement all methods and
|
||||
* behave as though it were unbuffered. More specifically:
|
||||
* </p>
|
||||
* <ul>
|
||||
* <li>clear() must throw an IOException</li>
|
||||
* <li>clearBuffer() does nothing</li>
|
||||
* <li>getBufferSize() always returns 0</li>
|
||||
* <li>getRemaining() always returns 0</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param writer The Writer for the returned JspWriter to send
|
||||
* output to.
|
||||
* @return a new JspWriter that writes to the given Writer.
|
||||
* @since 2.0
|
||||
*/
|
||||
public JspWriter pushBody( java.io.Writer writer ) {
|
||||
return null; // XXX to implement
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the previous JspWriter "out" saved by the matching
|
||||
* pushBody(), and update the value of the "out" attribute in
|
||||
* the page scope attribute namespace of the JspContext.
|
||||
*
|
||||
* @return the saved JspWriter.
|
||||
*/
|
||||
public JspWriter popBody() {
|
||||
return null; // XXX to implement
|
||||
}
|
||||
}
|
||||
49
java/javax/servlet/jsp/JspEngineInfo.java
Normal file
49
java/javax/servlet/jsp/JspEngineInfo.java
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp;
|
||||
|
||||
/**
|
||||
* The JspEngineInfo is an abstract class that provides information on the
|
||||
* current JSP engine.
|
||||
*/
|
||||
|
||||
public abstract class JspEngineInfo {
|
||||
|
||||
/**
|
||||
* Sole constructor. (For invocation by subclass constructors,
|
||||
* typically implicit.)
|
||||
*/
|
||||
public JspEngineInfo() {
|
||||
// NOOP by default
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the version number of the JSP specification that is supported by
|
||||
* this JSP engine.
|
||||
* <p>
|
||||
* Specification version numbers that consists of positive decimal integers
|
||||
* separated by periods ".", for example, "2.0" or "1.2.3.4.5.6.7".
|
||||
* This allows an extensible number to be used to
|
||||
* represent major, minor, micro, etc versions.
|
||||
* The version number must begin with a number.
|
||||
* </p>
|
||||
*
|
||||
* @return the specification version, null is returned if it is not known
|
||||
*/
|
||||
|
||||
public abstract String getSpecificationVersion();
|
||||
}
|
||||
101
java/javax/servlet/jsp/JspException.java
Normal file
101
java/javax/servlet/jsp/JspException.java
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp;
|
||||
|
||||
/**
|
||||
* A generic exception known to the JSP engine; uncaught
|
||||
* JspExceptions will result in an invocation of the errorpage
|
||||
* machinery.
|
||||
*/
|
||||
public class JspException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/**
|
||||
* Construct a JspException.
|
||||
*/
|
||||
public JspException() {
|
||||
// NOOP
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new JSP exception with the
|
||||
* specified message. The message can be written
|
||||
* to the server log and/or displayed for the user.
|
||||
*
|
||||
* @param msg a <code>String</code> specifying the text of the exception
|
||||
* message
|
||||
*/
|
||||
public JspException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new <code>JSPException</code> with the specified detail
|
||||
* message and cause. The cause is saved for later retrieval by the
|
||||
* <code>java.lang.Throwable.getCause()</code> and {@link #getRootCause()}
|
||||
* methods.
|
||||
*
|
||||
* @see java.lang.Exception#Exception(String, Throwable)
|
||||
*
|
||||
* @param message a <code>String</code> containing the text of the
|
||||
* exception message
|
||||
*
|
||||
* @param cause the <code>Throwable</code> exception that
|
||||
* interfered with the JSP's normal operation,
|
||||
* making this JSP exception necessary
|
||||
*/
|
||||
|
||||
public JspException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new <code>JSPException</code> with the specified cause.
|
||||
* The cause is saved for later retrieval by the
|
||||
* <code>java.lang.Throwable.getCause()</code> and {@link #getRootCause()}
|
||||
* methods.
|
||||
*
|
||||
* @see java.lang.Exception#Exception(Throwable)
|
||||
*
|
||||
* @param cause the <code>Throwable</code> exception that
|
||||
* interfered with the JSP's normal operation, making
|
||||
* the JSP exception necessary
|
||||
*/
|
||||
|
||||
public JspException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the exception that caused this JSP exception.
|
||||
*
|
||||
* @return the <code>Throwable</code> that caused this JSP exception
|
||||
*
|
||||
* @deprecated As of JSP 2.1, replaced by
|
||||
* <code>java.lang.Throwable.getCause()</code>
|
||||
*/
|
||||
@SuppressWarnings("dep-ann") // TCK signature test fails with annotation
|
||||
public Throwable getRootCause() {
|
||||
return getCause();
|
||||
}
|
||||
}
|
||||
157
java/javax/servlet/jsp/JspFactory.java
Normal file
157
java/javax/servlet/jsp/JspFactory.java
Normal file
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp;
|
||||
|
||||
import javax.servlet.Servlet;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* The JspFactory is an abstract class that defines a number of factory
|
||||
* methods available to a JSP page at runtime for the purposes of creating
|
||||
* instances of various interfaces and classes used to support the JSP
|
||||
* implementation.
|
||||
* <p>
|
||||
* A conformant JSP Engine implementation will, during it's initialization
|
||||
* instantiate an implementation dependent subclass of this class, and make
|
||||
* it globally available for use by JSP implementation classes by registering
|
||||
* the instance created with this class via the
|
||||
* static <code> setDefaultFactory() </code> method.
|
||||
* <p>
|
||||
* The PageContext and the JspEngineInfo classes are the only
|
||||
* implementation-dependent classes that can be created from the factory.
|
||||
* <p>
|
||||
* JspFactory objects should not be used by JSP page authors.
|
||||
*/
|
||||
|
||||
public abstract class JspFactory {
|
||||
|
||||
private static volatile JspFactory deflt = null;
|
||||
|
||||
/**
|
||||
* Sole constructor. (For invocation by subclass constructors,
|
||||
* typically implicit.)
|
||||
*/
|
||||
public JspFactory() {
|
||||
// NOOP by default
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* set the default factory for this implementation. It is illegal for
|
||||
* any principal other than the JSP Engine runtime to call this method.
|
||||
* </p>
|
||||
*
|
||||
* @param deflt The default factory implementation
|
||||
*/
|
||||
|
||||
public static void setDefaultFactory(JspFactory deflt) {
|
||||
JspFactory.deflt = deflt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default factory for this implementation.
|
||||
*
|
||||
* @return the default factory for this implementation
|
||||
*/
|
||||
|
||||
public static JspFactory getDefaultFactory() {
|
||||
return deflt;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* obtains an instance of an implementation dependent
|
||||
* javax.servlet.jsp.PageContext abstract class for the calling Servlet
|
||||
* and currently pending request and response.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* This method is typically called early in the processing of the
|
||||
* _jspService() method of a JSP implementation class in order to
|
||||
* obtain a PageContext object for the request being processed.
|
||||
* </p>
|
||||
* <p>
|
||||
* Invoking this method shall result in the PageContext.initialize()
|
||||
* method being invoked. The PageContext returned is properly initialized.
|
||||
* </p>
|
||||
* <p>
|
||||
* All PageContext objects obtained via this method shall be released
|
||||
* by invoking releasePageContext().
|
||||
* </p>
|
||||
*
|
||||
* @param servlet the requesting servlet
|
||||
* @param request the current request pending on the servlet
|
||||
* @param response the current response pending on the servlet
|
||||
* @param errorPageURL the URL of the error page for the requesting JSP, or
|
||||
* null
|
||||
* @param needsSession true if the JSP participates in a session
|
||||
* @param buffer size of buffer in bytes, {@link JspWriter#NO_BUFFER}
|
||||
* if no buffer, {@link JspWriter#DEFAULT_BUFFER}
|
||||
* if implementation default.
|
||||
* @param autoflush should the buffer autoflush to the output stream on
|
||||
* buffer overflow, or throw an IOException?
|
||||
*
|
||||
* @return the page context
|
||||
*
|
||||
* @see javax.servlet.jsp.PageContext
|
||||
*/
|
||||
|
||||
public abstract PageContext getPageContext(Servlet servlet,
|
||||
ServletRequest request, ServletResponse response,
|
||||
String errorPageURL, boolean needsSession, int buffer,
|
||||
boolean autoflush);
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* called to release a previously allocated PageContext object.
|
||||
* Results in PageContext.release() being invoked.
|
||||
* This method should be invoked prior to returning from the _jspService()
|
||||
* method of a JSP implementation class.
|
||||
* </p>
|
||||
*
|
||||
* @param pc A PageContext previously obtained by getPageContext()
|
||||
*/
|
||||
public abstract void releasePageContext(PageContext pc);
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* called to get implementation-specific information on the current JSP
|
||||
* engine.
|
||||
* </p>
|
||||
*
|
||||
* @return a JspEngineInfo object describing the current JSP engine
|
||||
*/
|
||||
|
||||
public abstract JspEngineInfo getEngineInfo();
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Obtain the <code>JspApplicationContext</code> instance that was
|
||||
* associated within the passed <code>ServletContext</code> for this web
|
||||
* application.
|
||||
* </p>
|
||||
*
|
||||
* @param context the current web application's <code>ServletContext</code>
|
||||
* @return <code>JspApplicationContext</code> instance
|
||||
* @since 2.1
|
||||
*/
|
||||
public abstract JspApplicationContext getJspApplicationContext(
|
||||
ServletContext context);
|
||||
}
|
||||
90
java/javax/servlet/jsp/JspPage.java
Normal file
90
java/javax/servlet/jsp/JspPage.java
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp;
|
||||
|
||||
import javax.servlet.Servlet;
|
||||
|
||||
/**
|
||||
* The JspPage interface describes the generic interaction that a JSP Page
|
||||
* Implementation class must satisfy; pages that use the HTTP protocol
|
||||
* are described by the HttpJspPage interface.
|
||||
*
|
||||
* <p><B>Two plus One Methods</B>
|
||||
* <p>
|
||||
* The interface defines a protocol with 3 methods; only two of
|
||||
* them: jspInit() and jspDestroy() are part of this interface as
|
||||
* the signature of the third method: _jspService() depends on
|
||||
* the specific protocol used and cannot be expressed in a generic
|
||||
* way in Java.
|
||||
* <p>
|
||||
* A class implementing this interface is responsible for invoking
|
||||
* the above methods at the appropriate time based on the
|
||||
* corresponding Servlet-based method invocations.
|
||||
* <p>
|
||||
* The jspInit() and jspDestroy() methods can be defined by a JSP
|
||||
* author, but the _jspService() method is defined automatically
|
||||
* by the JSP processor based on the contents of the JSP page.
|
||||
*
|
||||
* <p><B>_jspService()</B>
|
||||
* <p>
|
||||
* The _jspService()method corresponds to the body of the JSP page. This
|
||||
* method is defined automatically by the JSP container and should never
|
||||
* be defined by the JSP page author.
|
||||
* <p>
|
||||
* If a superclass is specified using the extends attribute, that
|
||||
* superclass may choose to perform some actions in its service() method
|
||||
* before or after calling the _jspService() method. See using the extends
|
||||
* attribute in the JSP_Engine chapter of the JSP specification.
|
||||
* <p>
|
||||
* The specific signature depends on the protocol supported by the JSP page.
|
||||
*
|
||||
* <pre>
|
||||
* public void _jspService(<em>ServletRequestSubtype</em> request,
|
||||
* <em>ServletResponseSubtype</em> response)
|
||||
* throws ServletException, IOException;
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
|
||||
public interface JspPage extends Servlet {
|
||||
|
||||
/**
|
||||
* The jspInit() method is invoked when the JSP page is initialized. It
|
||||
* is the responsibility of the JSP implementation (and of the class
|
||||
* mentioned by the extends attribute, if present) that at this point
|
||||
* invocations to the getServletConfig() method will return the desired
|
||||
* value.
|
||||
*
|
||||
* A JSP page can override this method by including a definition for it
|
||||
* in a declaration element.
|
||||
*
|
||||
* A JSP page should redefine the init() method from Servlet.
|
||||
*/
|
||||
public void jspInit();
|
||||
|
||||
/**
|
||||
* The jspDestroy() method is invoked when the JSP page is about to be
|
||||
* destroyed.
|
||||
*
|
||||
* A JSP page can override this method by including a definition for it
|
||||
* in a declaration element.
|
||||
*
|
||||
* A JSP page should redefine the destroy() method from Servlet.
|
||||
*/
|
||||
public void jspDestroy();
|
||||
|
||||
}
|
||||
85
java/javax/servlet/jsp/JspTagException.java
Normal file
85
java/javax/servlet/jsp/JspTagException.java
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp;
|
||||
|
||||
/**
|
||||
* Exception to be used by a Tag Handler to indicate some unrecoverable error.
|
||||
* This error is to be caught by the top level of the JSP page and will result
|
||||
* in an error page.
|
||||
*/
|
||||
public class JspTagException extends JspException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Constructs a new JspTagException with the specified message. The message
|
||||
* can be written to the server log and/or displayed for the user.
|
||||
*
|
||||
* @param msg
|
||||
* a <code>String</code> specifying the text of the exception
|
||||
* message
|
||||
*/
|
||||
public JspTagException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new JspTagException with no message.
|
||||
*/
|
||||
public JspTagException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new JspTagException when the JSP Tag needs to throw an
|
||||
* exception and include a message about the "root cause" exception that
|
||||
* interfered with its normal operation, including a description message.
|
||||
*
|
||||
* @param message
|
||||
* a <code>String</code> containing the text of the exception
|
||||
* message
|
||||
* @param rootCause
|
||||
* the <code>Throwable</code> exception that interfered with the
|
||||
* JSP Tag's normal operation, making this JSP Tag exception
|
||||
* necessary
|
||||
* @since 2.0
|
||||
*/
|
||||
public JspTagException(String message, Throwable rootCause) {
|
||||
super(message, rootCause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new JSP Tag exception when the JSP Tag needs to throw an
|
||||
* exception and include a message about the "root cause" exception that
|
||||
* interfered with its normal operation. The exception's message is based on
|
||||
* the localized message of the underlying exception.
|
||||
* <p>
|
||||
* This method calls the <code>getLocalizedMessage</code> method on the
|
||||
* <code>Throwable</code> exception to get a localized exception message.
|
||||
* When subclassing <code>JspTagException</code>, this method can be
|
||||
* overridden to create an exception message designed for a specific locale.
|
||||
*
|
||||
* @param rootCause
|
||||
* the <code>Throwable</code> exception that interfered with the
|
||||
* JSP Tag's normal operation, making the JSP Tag exception
|
||||
* necessary
|
||||
* @since 2.0
|
||||
*/
|
||||
public JspTagException(Throwable rootCause) {
|
||||
super(rootCause);
|
||||
}
|
||||
}
|
||||
458
java/javax/servlet/jsp/JspWriter.java
Normal file
458
java/javax/servlet/jsp/JspWriter.java
Normal file
@@ -0,0 +1,458 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* The actions and template data in a JSP page is written using the JspWriter
|
||||
* object that is referenced by the implicit variable out which is initialized
|
||||
* automatically using methods in the PageContext object.
|
||||
*<p>
|
||||
* This abstract class emulates some of the functionality found in the
|
||||
* java.io.BufferedWriter and java.io.PrintWriter classes, however it differs in
|
||||
* that it throws java.io.IOException from the print methods while PrintWriter
|
||||
* does not.
|
||||
* <p>
|
||||
* <B>Buffering</B>
|
||||
* <p>
|
||||
* The initial JspWriter object is associated with the PrintWriter object of the
|
||||
* ServletResponse in a way that depends on whether the page is or is not
|
||||
* buffered. If the page is not buffered, output written to this JspWriter
|
||||
* object will be written through to the PrintWriter directly, which will be
|
||||
* created if necessary by invoking the getWriter() method on the response
|
||||
* object. But if the page is buffered, the PrintWriter object will not be
|
||||
* created until the buffer is flushed and operations like setContentType() are
|
||||
* legal. Since this flexibility simplifies programming substantially, buffering
|
||||
* is the default for JSP pages.
|
||||
* <p>
|
||||
* Buffering raises the issue of what to do when the buffer is exceeded. Two
|
||||
* approaches can be taken:
|
||||
* <ul>
|
||||
* <li>Exceeding the buffer is not a fatal error; when the buffer is exceeded,
|
||||
* just flush the output.
|
||||
* <li>Exceeding the buffer is a fatal error; when the buffer is exceeded, raise
|
||||
* an exception.
|
||||
* </ul>
|
||||
* <p>
|
||||
* Both approaches are valid, and thus both are supported in the JSP technology.
|
||||
* The behavior of a page is controlled by the autoFlush attribute, which
|
||||
* defaults to true. In general, JSP pages that need to be sure that correct and
|
||||
* complete data has been sent to their client may want to set autoFlush to
|
||||
* false, with a typical case being that where the client is an application
|
||||
* itself. On the other hand, JSP pages that send data that is meaningful even
|
||||
* when partially constructed may want to set autoFlush to true; such as when
|
||||
* the data is sent for immediate display through a browser. Each application
|
||||
* will need to consider their specific needs.
|
||||
* <p>
|
||||
* An alternative considered was to make the buffer size unbounded; but, this
|
||||
* had the disadvantage that runaway computations would consume an unbounded
|
||||
* amount of resources.
|
||||
* <p>
|
||||
* The "out" implicit variable of a JSP implementation class is of this type. If
|
||||
* the page directive selects autoflush="true" then all the I/O operations on
|
||||
* this class shall automatically flush the contents of the buffer if an
|
||||
* overflow condition would result if the current operation were performed
|
||||
* without a flush. If autoflush="false" then all the I/O operations on this
|
||||
* class shall throw an IOException if performing the current operation would
|
||||
* result in a buffer overflow condition.
|
||||
*
|
||||
* @see java.io.Writer
|
||||
* @see java.io.BufferedWriter
|
||||
* @see java.io.PrintWriter
|
||||
*/
|
||||
public abstract class JspWriter extends java.io.Writer {
|
||||
|
||||
/**
|
||||
* Constant indicating that the Writer is not buffering output.
|
||||
*/
|
||||
public static final int NO_BUFFER = 0;
|
||||
|
||||
/**
|
||||
* Constant indicating that the Writer is buffered and is using the
|
||||
* implementation default buffer size.
|
||||
*/
|
||||
public static final int DEFAULT_BUFFER = -1;
|
||||
|
||||
/**
|
||||
* Constant indicating that the Writer is buffered and is unbounded; this is
|
||||
* used in BodyContent.
|
||||
*/
|
||||
public static final int UNBOUNDED_BUFFER = -2;
|
||||
|
||||
/**
|
||||
* Protected constructor.
|
||||
*
|
||||
* @param bufferSize
|
||||
* the size of the buffer to be used by the JspWriter
|
||||
* @param autoFlush
|
||||
* whether the JspWriter should be autoflushing
|
||||
*/
|
||||
protected JspWriter(int bufferSize, boolean autoFlush) {
|
||||
this.bufferSize = bufferSize;
|
||||
this.autoFlush = autoFlush;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a line separator. The line separator string is defined by the
|
||||
* system property <code>line.separator</code>, and is not necessarily a
|
||||
* single newline ('\n') character.
|
||||
*
|
||||
* @exception IOException
|
||||
* If an I/O error occurs
|
||||
*/
|
||||
public abstract void newLine() throws IOException;
|
||||
|
||||
/**
|
||||
* Print a boolean value. The string produced by <code>{@link
|
||||
* java.lang.String#valueOf(boolean)}</code>
|
||||
* is written to the JspWriter's buffer or, if no buffer is used, directly
|
||||
* to the underlying writer.
|
||||
*
|
||||
* @param b
|
||||
* The <code>boolean</code> to be printed
|
||||
* @throws java.io.IOException
|
||||
* If an error occurred while writing
|
||||
*/
|
||||
public abstract void print(boolean b) throws IOException;
|
||||
|
||||
/**
|
||||
* Print a character. The character is written to the JspWriter's buffer or,
|
||||
* if no buffer is used, directly to the underlying writer.
|
||||
*
|
||||
* @param c
|
||||
* The <code>char</code> to be printed
|
||||
* @throws java.io.IOException
|
||||
* If an error occurred while writing
|
||||
*/
|
||||
public abstract void print(char c) throws IOException;
|
||||
|
||||
/**
|
||||
* Print an integer. The string produced by <code>{@link
|
||||
* java.lang.String#valueOf(int)}</code>
|
||||
* is written to the JspWriter's buffer or, if no buffer is used, directly
|
||||
* to the underlying writer.
|
||||
*
|
||||
* @param i
|
||||
* The <code>int</code> to be printed
|
||||
* @see java.lang.Integer#toString(int)
|
||||
* @throws java.io.IOException
|
||||
* If an error occurred while writing
|
||||
*/
|
||||
public abstract void print(int i) throws IOException;
|
||||
|
||||
/**
|
||||
* Print a long integer. The string produced by <code>{@link
|
||||
* java.lang.String#valueOf(long)}</code>
|
||||
* is written to the JspWriter's buffer or, if no buffer is used, directly
|
||||
* to the underlying writer.
|
||||
*
|
||||
* @param l
|
||||
* The <code>long</code> to be printed
|
||||
* @see java.lang.Long#toString(long)
|
||||
* @throws java.io.IOException
|
||||
* If an error occurred while writing
|
||||
*/
|
||||
public abstract void print(long l) throws IOException;
|
||||
|
||||
/**
|
||||
* Print a floating-point number. The string produced by <code>{@link
|
||||
* java.lang.String#valueOf(float)}</code>
|
||||
* is written to the JspWriter's buffer or, if no buffer is used, directly
|
||||
* to the underlying writer.
|
||||
*
|
||||
* @param f
|
||||
* The <code>float</code> to be printed
|
||||
* @see java.lang.Float#toString(float)
|
||||
* @throws java.io.IOException
|
||||
* If an error occurred while writing
|
||||
*/
|
||||
public abstract void print(float f) throws IOException;
|
||||
|
||||
/**
|
||||
* Print a double-precision floating-point number. The string produced by
|
||||
* <code>{@link java.lang.String#valueOf(double)}</code> is written to the
|
||||
* JspWriter's buffer or, if no buffer is used, directly to the underlying
|
||||
* writer.
|
||||
*
|
||||
* @param d
|
||||
* The <code>double</code> to be printed
|
||||
* @see java.lang.Double#toString(double)
|
||||
* @throws java.io.IOException
|
||||
* If an error occurred while writing
|
||||
*/
|
||||
public abstract void print(double d) throws IOException;
|
||||
|
||||
/**
|
||||
* Print an array of characters. The characters are written to the
|
||||
* JspWriter's buffer or, if no buffer is used, directly to the underlying
|
||||
* writer.
|
||||
*
|
||||
* @param s
|
||||
* The array of chars to be printed
|
||||
* @throws NullPointerException
|
||||
* If <code>s</code> is <code>null</code>
|
||||
* @throws java.io.IOException
|
||||
* If an error occurred while writing
|
||||
*/
|
||||
public abstract void print(char s[]) throws IOException;
|
||||
|
||||
/**
|
||||
* Print a string. If the argument is <code>null</code> then the string
|
||||
* <code>"null"</code> is printed. Otherwise, the string's characters are
|
||||
* written to the JspWriter's buffer or, if no buffer is used, directly to
|
||||
* the underlying writer.
|
||||
*
|
||||
* @param s
|
||||
* The <code>String</code> to be printed
|
||||
* @throws java.io.IOException
|
||||
* If an error occurred while writing
|
||||
*/
|
||||
public abstract void print(String s) throws IOException;
|
||||
|
||||
/**
|
||||
* Print an object. The string produced by the <code>{@link
|
||||
* java.lang.String#valueOf(Object)}</code>
|
||||
* method is written to the JspWriter's buffer or, if no buffer is used,
|
||||
* directly to the underlying writer.
|
||||
*
|
||||
* @param obj
|
||||
* The <code>Object</code> to be printed
|
||||
* @see java.lang.Object#toString()
|
||||
* @throws java.io.IOException
|
||||
* If an error occurred while writing
|
||||
*/
|
||||
public abstract void print(Object obj) throws IOException;
|
||||
|
||||
/**
|
||||
* Terminate the current line by writing the line separator string. The line
|
||||
* separator string is defined by the system property
|
||||
* <code>line.separator</code>, and is not necessarily a single newline
|
||||
* character (<code>'\n'</code>).
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
* If an error occurred while writing
|
||||
*/
|
||||
public abstract void println() throws IOException;
|
||||
|
||||
/**
|
||||
* Print a boolean value and then terminate the line. This method behaves as
|
||||
* though it invokes <code>{@link #print(boolean)}</code> and then
|
||||
* <code>{@link #println()}</code>.
|
||||
*
|
||||
* @param x
|
||||
* the boolean to write
|
||||
* @throws java.io.IOException
|
||||
* If an error occurred while writing
|
||||
*/
|
||||
public abstract void println(boolean x) throws IOException;
|
||||
|
||||
/**
|
||||
* Print a character and then terminate the line. This method behaves as
|
||||
* though it invokes <code>{@link #print(char)}</code> and then <code>{@link
|
||||
* #println()}</code>
|
||||
* .
|
||||
*
|
||||
* @param x
|
||||
* the char to write
|
||||
* @throws java.io.IOException
|
||||
* If an error occurred while writing
|
||||
*/
|
||||
public abstract void println(char x) throws IOException;
|
||||
|
||||
/**
|
||||
* Print an integer and then terminate the line. This method behaves as
|
||||
* though it invokes <code>{@link #print(int)}</code> and then <code>{@link
|
||||
* #println()}</code>
|
||||
* .
|
||||
*
|
||||
* @param x
|
||||
* the int to write
|
||||
* @throws java.io.IOException
|
||||
* If an error occurred while writing
|
||||
*/
|
||||
public abstract void println(int x) throws IOException;
|
||||
|
||||
/**
|
||||
* Print a long integer and then terminate the line. This method behaves as
|
||||
* though it invokes <code>{@link #print(long)}</code> and then
|
||||
* <code>{@link #println()}</code>.
|
||||
*
|
||||
* @param x
|
||||
* the long to write
|
||||
* @throws java.io.IOException
|
||||
* If an error occurred while writing
|
||||
*/
|
||||
public abstract void println(long x) throws IOException;
|
||||
|
||||
/**
|
||||
* Print a floating-point number and then terminate the line. This method
|
||||
* behaves as though it invokes <code>{@link #print(float)}</code> and then
|
||||
* <code>{@link #println()}</code>.
|
||||
*
|
||||
* @param x
|
||||
* the float to write
|
||||
* @throws java.io.IOException
|
||||
* If an error occurred while writing
|
||||
*/
|
||||
public abstract void println(float x) throws IOException;
|
||||
|
||||
/**
|
||||
* Print a double-precision floating-point number and then terminate the
|
||||
* line. This method behaves as though it invokes <code>{@link
|
||||
* #print(double)}</code> and
|
||||
* then <code>{@link #println()}</code>.
|
||||
*
|
||||
* @param x
|
||||
* the double to write
|
||||
* @throws java.io.IOException
|
||||
* If an error occurred while writing
|
||||
*/
|
||||
public abstract void println(double x) throws IOException;
|
||||
|
||||
/**
|
||||
* Print an array of characters and then terminate the line. This method
|
||||
* behaves as though it invokes <code>print(char[])</code> and then
|
||||
* <code>println()</code>.
|
||||
*
|
||||
* @param x
|
||||
* the char[] to write
|
||||
* @throws java.io.IOException
|
||||
* If an error occurred while writing
|
||||
*/
|
||||
public abstract void println(char x[]) throws IOException;
|
||||
|
||||
/**
|
||||
* Print a String and then terminate the line. This method behaves as though
|
||||
* it invokes <code>{@link #print(String)}</code> and then
|
||||
* <code>{@link #println()}</code>.
|
||||
*
|
||||
* @param x
|
||||
* the String to write
|
||||
* @throws java.io.IOException
|
||||
* If an error occurred while writing
|
||||
*/
|
||||
public abstract void println(String x) throws IOException;
|
||||
|
||||
/**
|
||||
* Print an Object and then terminate the line. This method behaves as
|
||||
* though it invokes <code>{@link #print(Object)}</code> and then
|
||||
* <code>{@link #println()}</code>.
|
||||
*
|
||||
* @param x
|
||||
* the Object to write
|
||||
* @throws java.io.IOException
|
||||
* If an error occurred while writing
|
||||
*/
|
||||
public abstract void println(Object x) throws IOException;
|
||||
|
||||
/**
|
||||
* Clear the contents of the buffer. If the buffer has been already been
|
||||
* flushed then the clear operation shall throw an IOException to signal the
|
||||
* fact that some data has already been irrevocably written to the client
|
||||
* response stream.
|
||||
*
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
*/
|
||||
public abstract void clear() throws IOException;
|
||||
|
||||
/**
|
||||
* Clears the current contents of the buffer. Unlike clear(), this method
|
||||
* will not throw an IOException if the buffer has already been flushed. It
|
||||
* merely clears the current content of the buffer and returns.
|
||||
*
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
*/
|
||||
public abstract void clearBuffer() throws IOException;
|
||||
|
||||
/**
|
||||
* Flush the stream. If the stream has saved any characters from the various
|
||||
* write() methods in a buffer, write them immediately to their intended
|
||||
* destination. Then, if that destination is another character or byte
|
||||
* stream, flush it. Thus one flush() invocation will flush all the buffers
|
||||
* in a chain of Writers and OutputStreams.
|
||||
* <p>
|
||||
* The method may be invoked indirectly if the buffer size is exceeded.
|
||||
* <p>
|
||||
* Once a stream has been closed, further write() or flush() invocations
|
||||
* will cause an IOException to be thrown.
|
||||
*
|
||||
* @exception IOException
|
||||
* If an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
public abstract void flush() throws IOException;
|
||||
|
||||
/**
|
||||
* Close the stream, flushing it first.
|
||||
* <p>
|
||||
* This method needs not be invoked explicitly for the initial JspWriter as
|
||||
* the code generated by the JSP container will automatically include a call
|
||||
* to close().
|
||||
* <p>
|
||||
* Closing a previously-closed stream, unlike flush(), has no effect.
|
||||
*
|
||||
* @exception IOException
|
||||
* If an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
public abstract void close() throws IOException;
|
||||
|
||||
/**
|
||||
* This method returns the size of the buffer used by the JspWriter.
|
||||
*
|
||||
* @return the size of the buffer in bytes, or 0 is unbuffered.
|
||||
*/
|
||||
public int getBufferSize() {
|
||||
return bufferSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the number of unused bytes in the buffer.
|
||||
*
|
||||
* @return the number of bytes unused in the buffer
|
||||
*/
|
||||
public abstract int getRemaining();
|
||||
|
||||
/**
|
||||
* This method indicates whether the JspWriter is autoFlushing.
|
||||
*
|
||||
* @return if this JspWriter is auto flushing or throwing IOExceptions on
|
||||
* buffer overflow conditions
|
||||
*/
|
||||
public boolean isAutoFlush() {
|
||||
return autoFlush;
|
||||
}
|
||||
|
||||
/*
|
||||
* fields
|
||||
*/
|
||||
|
||||
/**
|
||||
* The size of the buffer used by the JspWriter.
|
||||
*/
|
||||
protected int bufferSize;
|
||||
|
||||
/**
|
||||
* Whether the JspWriter is autoflushing.
|
||||
*/
|
||||
protected boolean autoFlush;
|
||||
}
|
||||
535
java/javax/servlet/jsp/PageContext.java
Normal file
535
java/javax/servlet/jsp/PageContext.java
Normal file
@@ -0,0 +1,535 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.Servlet;
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.servlet.jsp.tagext.BodyContent;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* PageContext extends JspContext to provide useful context information for
|
||||
* when JSP technology is used in a Servlet environment.
|
||||
* <p>
|
||||
* A PageContext instance provides access to all the namespaces associated
|
||||
* with a JSP page, provides access to several page attributes, as well as
|
||||
* a layer above the implementation details. Implicit objects are added
|
||||
* to the pageContext automatically.
|
||||
*
|
||||
* <p> The <code> PageContext </code> class is an abstract class, designed to be
|
||||
* extended to provide implementation dependent implementations thereof, by
|
||||
* conformant JSP engine runtime environments. A PageContext instance is
|
||||
* obtained by a JSP implementation class by calling the
|
||||
* JspFactory.getPageContext() method, and is released by calling
|
||||
* JspFactory.releasePageContext().
|
||||
*
|
||||
* <p> An example of how PageContext, JspFactory, and other classes can be
|
||||
* used within a JSP Page Implementation object is given elsewhere.
|
||||
*
|
||||
* <p>
|
||||
* The PageContext provides a number of facilities to the page/component
|
||||
* author and page implementor, including:
|
||||
* <ul>
|
||||
* <li>a single API to manage the various scoped namespaces
|
||||
* <li>a number of convenience API's to access various public objects
|
||||
* <li>a mechanism to obtain the JspWriter for output
|
||||
* <li>a mechanism to manage session usage by the page
|
||||
* <li>a mechanism to expose page directive attributes to the scripting
|
||||
* environment
|
||||
* <li>mechanisms to forward or include the current request to other active
|
||||
* components in the application
|
||||
* <li>a mechanism to handle errorpage exception processing
|
||||
* </ul>
|
||||
*
|
||||
* <p><B>Methods Intended for Container Generated Code</B>
|
||||
* <p>Some methods are intended to be used by the code generated by the
|
||||
* container, not by code written by JSP page authors, or JSP tag library
|
||||
* authors.
|
||||
* <p>The methods supporting <B>lifecycle</B> are <code>initialize()</code>
|
||||
* and <code>release()</code>
|
||||
*
|
||||
* <p>
|
||||
* The following methods enable the <B>management of nested</B> JspWriter
|
||||
* streams to implement Tag Extensions: <code>pushBody()</code>
|
||||
*
|
||||
* <p><B>Methods Intended for JSP authors</B>
|
||||
* <p>
|
||||
* The following methods provide <B>convenient access</B> to implicit objects:
|
||||
* <code>getException()</code>, <code>getPage()</code>
|
||||
* <code>getRequest()</code>, <code>getResponse()</code>,
|
||||
* <code>getSession()</code>, <code>getServletConfig()</code>
|
||||
* and <code>getServletContext()</code>.
|
||||
*
|
||||
* <p>
|
||||
* The following methods provide support for <B>forwarding, inclusion
|
||||
* and error handling</B>:
|
||||
* <code>forward()</code>, <code>include()</code>,
|
||||
* and <code>handlePageException()</code>.
|
||||
*/
|
||||
|
||||
public abstract class PageContext
|
||||
extends JspContext
|
||||
{
|
||||
|
||||
/**
|
||||
* Sole constructor. (For invocation by subclass constructors,
|
||||
* typically implicit.)
|
||||
*/
|
||||
public PageContext() {
|
||||
// NOOP by default
|
||||
}
|
||||
|
||||
/**
|
||||
* Page scope: (this is the default) the named reference remains available
|
||||
* in this PageContext until the return from the current Servlet.service()
|
||||
* invocation.
|
||||
*/
|
||||
|
||||
public static final int PAGE_SCOPE = 1;
|
||||
|
||||
/**
|
||||
* Request scope: the named reference remains available from the
|
||||
* ServletRequest associated with the Servlet until the current request
|
||||
* is completed.
|
||||
*/
|
||||
|
||||
public static final int REQUEST_SCOPE = 2;
|
||||
|
||||
/**
|
||||
* Session scope (only valid if this page participates in a session):
|
||||
* the named reference remains available from the HttpSession (if any)
|
||||
* associated with the Servlet until the HttpSession is invalidated.
|
||||
*/
|
||||
|
||||
public static final int SESSION_SCOPE = 3;
|
||||
|
||||
/**
|
||||
* Application scope: named reference remains available in the
|
||||
* ServletContext until it is reclaimed.
|
||||
*/
|
||||
|
||||
public static final int APPLICATION_SCOPE = 4;
|
||||
|
||||
/**
|
||||
* Name used to store the Servlet in this PageContext's nametables.
|
||||
*/
|
||||
|
||||
public static final String PAGE = "javax.servlet.jsp.jspPage";
|
||||
|
||||
/**
|
||||
* Name used to store this PageContext in it's own name table.
|
||||
*/
|
||||
|
||||
public static final String PAGECONTEXT = "javax.servlet.jsp.jspPageContext";
|
||||
|
||||
/**
|
||||
* Name used to store ServletRequest in PageContext name table.
|
||||
*/
|
||||
|
||||
public static final String REQUEST = "javax.servlet.jsp.jspRequest";
|
||||
|
||||
/**
|
||||
* Name used to store ServletResponse in PageContext name table.
|
||||
*/
|
||||
|
||||
public static final String RESPONSE = "javax.servlet.jsp.jspResponse";
|
||||
|
||||
/**
|
||||
* Name used to store ServletConfig in PageContext name table.
|
||||
*/
|
||||
|
||||
public static final String CONFIG = "javax.servlet.jsp.jspConfig";
|
||||
|
||||
/**
|
||||
* Name used to store HttpSession in PageContext name table.
|
||||
*/
|
||||
|
||||
public static final String SESSION = "javax.servlet.jsp.jspSession";
|
||||
/**
|
||||
* Name used to store current JspWriter in PageContext name table.
|
||||
*/
|
||||
|
||||
public static final String OUT = "javax.servlet.jsp.jspOut";
|
||||
|
||||
/**
|
||||
* Name used to store ServletContext in PageContext name table.
|
||||
*/
|
||||
|
||||
public static final String APPLICATION = "javax.servlet.jsp.jspApplication";
|
||||
|
||||
/**
|
||||
* Name used to store uncaught exception in ServletRequest attribute
|
||||
* list and PageContext name table.
|
||||
*/
|
||||
|
||||
public static final String EXCEPTION = "javax.servlet.jsp.jspException";
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* The initialize method is called to initialize an uninitialized PageContext
|
||||
* so that it may be used by a JSP Implementation class to service an
|
||||
* incoming request and response within it's _jspService() method.
|
||||
*
|
||||
* <p>
|
||||
* This method is typically called from JspFactory.getPageContext() in
|
||||
* order to initialize state.
|
||||
*
|
||||
* <p>
|
||||
* This method is required to create an initial JspWriter, and associate
|
||||
* the "out" name in page scope with this newly created object.
|
||||
*
|
||||
* <p>
|
||||
* This method should not be used by page or tag library authors.
|
||||
*
|
||||
* @param servlet The Servlet that is associated with this PageContext
|
||||
* @param request The currently pending request for this Servlet
|
||||
* @param response The currently pending response for this Servlet
|
||||
* @param errorPageURL The value of the errorpage attribute from the page
|
||||
* directive or null
|
||||
* @param needsSession The value of the session attribute from the
|
||||
* page directive
|
||||
* @param bufferSize The value of the buffer attribute from the page
|
||||
* directive
|
||||
* @param autoFlush The value of the autoflush attribute from the page
|
||||
* directive
|
||||
*
|
||||
* @throws IOException during creation of JspWriter
|
||||
* @throws IllegalStateException if out not correctly initialized
|
||||
* @throws IllegalArgumentException If one of the given parameters
|
||||
* is invalid
|
||||
*/
|
||||
|
||||
public abstract void initialize(Servlet servlet, ServletRequest request,
|
||||
ServletResponse response, String errorPageURL, boolean needsSession,
|
||||
int bufferSize, boolean autoFlush)
|
||||
throws IOException, IllegalStateException, IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This method shall "reset" the internal state of a PageContext, releasing
|
||||
* all internal references, and preparing the PageContext for potential
|
||||
* reuse by a later invocation of initialize(). This method is typically
|
||||
* called from JspFactory.releasePageContext().
|
||||
*
|
||||
* <p>
|
||||
* Subclasses shall envelope this method.
|
||||
*
|
||||
* <p>
|
||||
* This method should not be used by page or tag library authors.
|
||||
*
|
||||
*/
|
||||
|
||||
public abstract void release();
|
||||
|
||||
/**
|
||||
* The current value of the session object (an HttpSession).
|
||||
*
|
||||
* @return the HttpSession for this PageContext or null
|
||||
*/
|
||||
|
||||
public abstract HttpSession getSession();
|
||||
|
||||
/**
|
||||
* The current value of the page object (In a Servlet environment,
|
||||
* this is an instance of javax.servlet.Servlet).
|
||||
*
|
||||
* @return the Page implementation class instance associated
|
||||
* with this PageContext
|
||||
*/
|
||||
|
||||
public abstract Object getPage();
|
||||
|
||||
|
||||
/**
|
||||
* The current value of the request object (a ServletRequest).
|
||||
*
|
||||
* @return The ServletRequest for this PageContext
|
||||
*/
|
||||
|
||||
public abstract ServletRequest getRequest();
|
||||
|
||||
/**
|
||||
* The current value of the response object (a ServletResponse).
|
||||
*
|
||||
* @return the ServletResponse for this PageContext
|
||||
*/
|
||||
|
||||
public abstract ServletResponse getResponse();
|
||||
|
||||
/**
|
||||
* The current value of the exception object (an Exception).
|
||||
*
|
||||
* @return any exception passed to this as an errorpage
|
||||
*/
|
||||
|
||||
public abstract Exception getException();
|
||||
|
||||
/**
|
||||
* The ServletConfig instance.
|
||||
*
|
||||
* @return the ServletConfig for this PageContext
|
||||
*/
|
||||
|
||||
public abstract ServletConfig getServletConfig();
|
||||
|
||||
/**
|
||||
* The ServletContext instance.
|
||||
*
|
||||
* @return the ServletContext for this PageContext
|
||||
*/
|
||||
|
||||
public abstract ServletContext getServletContext();
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This method is used to re-direct, or "forward" the current
|
||||
* ServletRequest and ServletResponse to another active component in
|
||||
* the application.
|
||||
* </p>
|
||||
* <p>
|
||||
* If the <I> relativeUrlPath </I> begins with a "/" then the URL specified
|
||||
* is calculated relative to the DOCROOT of the <code> ServletContext </code>
|
||||
* for this JSP. If the path does not begin with a "/" then the URL
|
||||
* specified is calculated relative to the URL of the request that was
|
||||
* mapped to the calling JSP.
|
||||
* </p>
|
||||
* <p>
|
||||
* It is only valid to call this method from a <code> Thread </code>
|
||||
* executing within a <code> _jspService(...) </code> method of a JSP.
|
||||
* </p>
|
||||
* <p>
|
||||
* Once this method has been called successfully, it is illegal for the
|
||||
* calling <code> Thread </code> to attempt to modify the <code>
|
||||
* ServletResponse </code> object. Any such attempt to do so, shall result
|
||||
* in undefined behavior. Typically, callers immediately return from
|
||||
* <code> _jspService(...) </code> after calling this method.
|
||||
* </p>
|
||||
*
|
||||
* @param relativeUrlPath specifies the relative URL path to the target
|
||||
* resource as described above
|
||||
*
|
||||
* @throws IllegalStateException if <code> ServletResponse </code> is not
|
||||
* in a state where a forward can be performed
|
||||
* @throws ServletException if the page that was forwarded to throws
|
||||
* a ServletException
|
||||
* @throws IOException if an I/O error occurred while forwarding
|
||||
*/
|
||||
|
||||
public abstract void forward(String relativeUrlPath)
|
||||
throws ServletException, IOException;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Causes the resource specified to be processed as part of the current
|
||||
* ServletRequest and ServletResponse being processed by the calling Thread.
|
||||
* The output of the target resources processing of the request is written
|
||||
* directly to the ServletResponse output stream.
|
||||
* </p>
|
||||
* <p>
|
||||
* The current JspWriter "out" for this JSP is flushed as a side-effect
|
||||
* of this call, prior to processing the include.
|
||||
* </p>
|
||||
* <p>
|
||||
* If the <I> relativeUrlPath </I> begins with a "/" then the URL specified
|
||||
* is calculated relative to the DOCROOT of the <code>ServletContext</code>
|
||||
* for this JSP. If the path does not begin with a "/" then the URL
|
||||
* specified is calculated relative to the URL of the request that was
|
||||
* mapped to the calling JSP.
|
||||
* </p>
|
||||
* <p>
|
||||
* It is only valid to call this method from a <code> Thread </code>
|
||||
* executing within a <code> _jspService(...) </code> method of a JSP.
|
||||
* </p>
|
||||
*
|
||||
* @param relativeUrlPath specifies the relative URL path to the target
|
||||
* resource to be included
|
||||
*
|
||||
* @throws ServletException if the page that was forwarded to throws
|
||||
* a ServletException
|
||||
* @throws IOException if an I/O error occurred while forwarding
|
||||
*/
|
||||
public abstract void include(String relativeUrlPath)
|
||||
throws ServletException, IOException;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Causes the resource specified to be processed as part of the current
|
||||
* ServletRequest and ServletResponse being processed by the calling Thread.
|
||||
* The output of the target resources processing of the request is written
|
||||
* directly to the current JspWriter returned by a call to getOut().
|
||||
* </p>
|
||||
* <p>
|
||||
* If flush is true, The current JspWriter "out" for this JSP
|
||||
* is flushed as a side-effect of this call, prior to processing
|
||||
* the include. Otherwise, the JspWriter "out" is not flushed.
|
||||
* </p>
|
||||
* <p>
|
||||
* If the <i>relativeUrlPath</i> begins with a "/" then the URL specified
|
||||
* is calculated relative to the DOCROOT of the <code>ServletContext</code>
|
||||
* for this JSP. If the path does not begin with a "/" then the URL
|
||||
* specified is calculated relative to the URL of the request that was
|
||||
* mapped to the calling JSP.
|
||||
* </p>
|
||||
* <p>
|
||||
* It is only valid to call this method from a <code> Thread </code>
|
||||
* executing within a <code> _jspService(...) </code> method of a JSP.
|
||||
* </p>
|
||||
*
|
||||
* @param relativeUrlPath specifies the relative URL path to the
|
||||
* target resource to be included
|
||||
* @param flush True if the JspWriter is to be flushed before the include,
|
||||
* or false if not.
|
||||
*
|
||||
* @throws ServletException if the page that was forwarded to throws
|
||||
* a ServletException
|
||||
* @throws IOException if an I/O error occurred while forwarding
|
||||
* @since 2.0
|
||||
*/
|
||||
public abstract void include(String relativeUrlPath, boolean flush)
|
||||
throws ServletException, IOException;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This method is intended to process an unhandled 'page' level
|
||||
* exception by forwarding the exception to the specified
|
||||
* error page for this JSP. If forwarding is not possible (for
|
||||
* example because the response has already been committed), an
|
||||
* implementation dependent mechanism should be used to invoke
|
||||
* the error page (e.g. "including" the error page instead).
|
||||
*
|
||||
* <p>
|
||||
* If no error page is defined in the page, the exception should
|
||||
* be rethrown so that the standard servlet error handling
|
||||
* takes over.
|
||||
*
|
||||
* <p>
|
||||
* A JSP implementation class shall typically clean up any local state
|
||||
* prior to invoking this and will return immediately thereafter. It is
|
||||
* illegal to generate any output to the client, or to modify any
|
||||
* ServletResponse state after invoking this call.
|
||||
*
|
||||
* <p>
|
||||
* This method is kept for backwards compatibility reasons. Newly
|
||||
* generated code should use PageContext.handlePageException(Throwable).
|
||||
*
|
||||
* @param e the exception to be handled
|
||||
*
|
||||
* @throws ServletException if an error occurs while invoking the error page
|
||||
* @throws IOException if an I/O error occurred while invoking the error
|
||||
* page
|
||||
* @throws NullPointerException if the exception is null
|
||||
*
|
||||
* @see #handlePageException(Throwable)
|
||||
*/
|
||||
|
||||
public abstract void handlePageException(Exception e)
|
||||
throws ServletException, IOException;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This method is intended to process an unhandled 'page' level
|
||||
* exception by forwarding the exception to the specified
|
||||
* error page for this JSP. If forwarding is not possible (for
|
||||
* example because the response has already been committed), an
|
||||
* implementation dependent mechanism should be used to invoke
|
||||
* the error page (e.g. "including" the error page instead).
|
||||
*
|
||||
* <p>
|
||||
* If no error page is defined in the page, the exception should
|
||||
* be rethrown so that the standard servlet error handling
|
||||
* takes over.
|
||||
*
|
||||
* <p>
|
||||
* This method is intended to process an unhandled "page" level exception
|
||||
* by redirecting the exception to either the specified error page for this
|
||||
* JSP, or if none was specified, to perform some implementation dependent
|
||||
* action.
|
||||
*
|
||||
* <p>
|
||||
* A JSP implementation class shall typically clean up any local state
|
||||
* prior to invoking this and will return immediately thereafter. It is
|
||||
* illegal to generate any output to the client, or to modify any
|
||||
* ServletResponse state after invoking this call.
|
||||
*
|
||||
* @param t the throwable to be handled
|
||||
*
|
||||
* @throws ServletException if an error occurs while invoking the error page
|
||||
* @throws IOException if an I/O error occurred while invoking the error
|
||||
* page
|
||||
* @throws NullPointerException if the exception is null
|
||||
*
|
||||
* @see #handlePageException(Exception)
|
||||
*/
|
||||
|
||||
public abstract void handlePageException(Throwable t)
|
||||
throws ServletException, IOException;
|
||||
|
||||
/**
|
||||
* Return a new BodyContent object, save the current "out" JspWriter,
|
||||
* and update the value of the "out" attribute in the page scope
|
||||
* attribute namespace of the PageContext.
|
||||
*
|
||||
* @return the new BodyContent
|
||||
*/
|
||||
|
||||
public BodyContent pushBody() {
|
||||
return null; // XXX to implement
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Provides convenient access to error information.
|
||||
*
|
||||
* @return an ErrorData instance containing information about the
|
||||
* error, as obtained from the request attributes, as per the
|
||||
* Servlet specification. If this is not an error page (that is,
|
||||
* if the isErrorPage attribute of the page directive is not set
|
||||
* to "true"), the information is meaningless.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public ErrorData getErrorData() {
|
||||
int status = 0;
|
||||
|
||||
Integer status_code = (Integer)getRequest().getAttribute(
|
||||
RequestDispatcher.ERROR_STATUS_CODE);
|
||||
// Avoid NPE if attribute is not set
|
||||
if (status_code != null) {
|
||||
status = status_code.intValue();
|
||||
}
|
||||
|
||||
return new ErrorData(
|
||||
(Throwable)getRequest().getAttribute(
|
||||
RequestDispatcher.ERROR_EXCEPTION),
|
||||
status,
|
||||
(String)getRequest().getAttribute(
|
||||
RequestDispatcher.ERROR_REQUEST_URI),
|
||||
(String)getRequest().getAttribute(
|
||||
RequestDispatcher.ERROR_SERVLET_NAME)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
77
java/javax/servlet/jsp/SkipPageException.java
Normal file
77
java/javax/servlet/jsp/SkipPageException.java
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp;
|
||||
|
||||
/**
|
||||
* Exception to indicate the calling page must cease evaluation. Thrown by a
|
||||
* simple tag handler to indicate that the remainder of the page must not be
|
||||
* evaluated. The result is propagated back to the page in the case where one
|
||||
* tag invokes another (as can be the case with tag files). The effect is
|
||||
* similar to that of a Classic Tag Handler returning Tag.SKIP_PAGE from
|
||||
* doEndTag(). Jsp Fragments may also throw this exception. This exception
|
||||
* should not be thrown manually in a JSP page or tag file - the behavior is
|
||||
* undefined. The exception is intended to be thrown inside SimpleTag handlers
|
||||
* and in JSP fragments.
|
||||
*
|
||||
* @see javax.servlet.jsp.tagext.SimpleTag#doTag
|
||||
* @see javax.servlet.jsp.tagext.JspFragment#invoke
|
||||
* @see javax.servlet.jsp.tagext.Tag#doEndTag
|
||||
* @since 2.0
|
||||
*/
|
||||
public class SkipPageException extends JspException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Creates a SkipPageException with no message.
|
||||
*/
|
||||
public SkipPageException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a SkipPageException with the provided message.
|
||||
*
|
||||
* @param message
|
||||
* the detail message
|
||||
*/
|
||||
public SkipPageException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a SkipPageException with the provided message and root cause.
|
||||
*
|
||||
* @param message
|
||||
* the detail message
|
||||
* @param rootCause
|
||||
* the originating cause of this exception
|
||||
*/
|
||||
public SkipPageException(String message, Throwable rootCause) {
|
||||
super(message, rootCause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a SkipPageException with the provided root cause.
|
||||
*
|
||||
* @param rootCause
|
||||
* the originating cause of this exception
|
||||
*/
|
||||
public SkipPageException(Throwable rootCause) {
|
||||
super(rootCause);
|
||||
}
|
||||
}
|
||||
81
java/javax/servlet/jsp/el/ELException.java
Normal file
81
java/javax/servlet/jsp/el/ELException.java
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.el;
|
||||
|
||||
/**
|
||||
* Represents any of the exception conditions that arise during the operation
|
||||
* evaluation of the evaluator.
|
||||
*
|
||||
* @since 2.0
|
||||
* @deprecated As of JSP 2.1, replaced by javax.el.ELException
|
||||
*/
|
||||
@SuppressWarnings("dep-ann") // TCK signature test fails with annotation
|
||||
public class ELException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Creates an ELException with no detail message.
|
||||
**/
|
||||
public ELException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an ELException with the provided detail message.
|
||||
*
|
||||
* @param pMessage
|
||||
* the detail message
|
||||
**/
|
||||
public ELException(String pMessage) {
|
||||
super(pMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an ELException with the given root cause.
|
||||
*
|
||||
* @param pRootCause
|
||||
* the originating cause of this exception
|
||||
**/
|
||||
public ELException(Throwable pRootCause) {
|
||||
super(pRootCause);
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
/**
|
||||
* Creates an ELException with the given detail message and root cause.
|
||||
*
|
||||
* @param pMessage
|
||||
* the detail message
|
||||
* @param pRootCause
|
||||
* the originating cause of this exception
|
||||
**/
|
||||
public ELException(String pMessage, Throwable pRootCause) {
|
||||
super(pMessage, pRootCause);
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
/**
|
||||
* Returns the root cause.
|
||||
*
|
||||
* @return the root cause of this exception
|
||||
*/
|
||||
public Throwable getRootCause() {
|
||||
return getCause();
|
||||
}
|
||||
}
|
||||
53
java/javax/servlet/jsp/el/ELParseException.java
Normal file
53
java/javax/servlet/jsp/el/ELParseException.java
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.el;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a parsing error encountered while parsing an EL expression.
|
||||
*
|
||||
* @since 2.0
|
||||
* @deprecated As of JSP 2.1, replaced by javax.el.ELException
|
||||
*/
|
||||
@SuppressWarnings("dep-ann") // TCK signature test fails with annotation
|
||||
public class ELParseException extends ELException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
//-------------------------------------
|
||||
/**
|
||||
* Creates an ELParseException with no detail message.
|
||||
*/
|
||||
public ELParseException ()
|
||||
{
|
||||
super ();
|
||||
}
|
||||
|
||||
//-------------------------------------
|
||||
/**
|
||||
* Creates an ELParseException with the provided detail message.
|
||||
*
|
||||
* @param pMessage the detail message
|
||||
**/
|
||||
public ELParseException (String pMessage)
|
||||
{
|
||||
super (pMessage);
|
||||
}
|
||||
|
||||
//-------------------------------------
|
||||
}
|
||||
54
java/javax/servlet/jsp/el/Expression.java
Normal file
54
java/javax/servlet/jsp/el/Expression.java
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.el;
|
||||
|
||||
|
||||
/**
|
||||
* <p>The abstract class for a prepared expression.</p>
|
||||
*
|
||||
* <p>An instance of an Expression can be obtained via from an
|
||||
* ExpressionEvaluator instance.</p>
|
||||
*
|
||||
* <p>An Expression may or not have done a syntactic parse of the expression.
|
||||
* A client invoking the evaluate() method should be ready for the case
|
||||
* where ELParseException exceptions are raised. </p>
|
||||
*
|
||||
* @since 2.0
|
||||
* @deprecated As of JSP 2.1, replaced by javax.el.ValueExpression
|
||||
*/
|
||||
@SuppressWarnings("dep-ann") // TCK signature test fails with annotation
|
||||
public abstract class Expression {
|
||||
|
||||
/**
|
||||
* Evaluates an expression that was previously prepared. In some
|
||||
* implementations preparing an expression involves full syntactic
|
||||
* validation, but others may not do so. Evaluating the expression may
|
||||
* raise an ELParseException as well as other ELExceptions due to
|
||||
* run-time evaluation.
|
||||
*
|
||||
* @param vResolver A VariableResolver instance that can be used at
|
||||
* runtime to resolve the name of implicit objects into Objects.
|
||||
* @return The result of the expression evaluation.
|
||||
*
|
||||
* @exception ELException Thrown if the expression evaluation failed.
|
||||
*/
|
||||
public abstract Object evaluate( VariableResolver vResolver )
|
||||
throws ELException;
|
||||
}
|
||||
|
||||
115
java/javax/servlet/jsp/el/ExpressionEvaluator.java
Normal file
115
java/javax/servlet/jsp/el/ExpressionEvaluator.java
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.el;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* The abstract base class for an expression-language evaluator. Classes that
|
||||
* implement an expression language expose their functionality via this abstract
|
||||
* class.
|
||||
* </p>
|
||||
* <p>
|
||||
* An instance of the ExpressionEvaluator can be obtained via the JspContext /
|
||||
* PageContext
|
||||
* </p>
|
||||
* <p>
|
||||
* The parseExpression() and evaluate() methods must be thread-safe. That is,
|
||||
* multiple threads may call these methods on the same ExpressionEvaluator
|
||||
* object simultaneously. Implementations should synchronize access if they
|
||||
* depend on transient state. Implementations should not, however, assume that
|
||||
* only one object of each ExpressionEvaluator type will be instantiated; global
|
||||
* caching should therefore be static.
|
||||
* </p>
|
||||
* <p>
|
||||
* Only a single EL expression, starting with '${' and ending with '}', can be
|
||||
* parsed or evaluated at a time. EL expressions cannot be mixed with static
|
||||
* text. For example, attempting to parse or evaluate "
|
||||
* <code>abc${1+1}def${1+1}ghi</code>" or even "<code>${1+1}${1+1}</code>" will
|
||||
* cause an <code>ELException</code> to be thrown.
|
||||
* </p>
|
||||
* <p>
|
||||
* The following are examples of syntactically legal EL expressions:
|
||||
* </p>
|
||||
* <ul>
|
||||
* <li><code>${person.lastName}</code></li>
|
||||
* <li><code>${8 * 8}</code></li>
|
||||
* <li><code>${my:reverse('hello')}</code></li>
|
||||
* </ul>
|
||||
*
|
||||
* @since 2.0
|
||||
* @deprecated As of JSP 2.1, replaced by javax.el.ExpressionFactory
|
||||
*/
|
||||
@SuppressWarnings("dep-ann")
|
||||
// TCK signature test fails with annotation
|
||||
public abstract class ExpressionEvaluator {
|
||||
|
||||
/**
|
||||
* Prepare an expression for later evaluation. This method should perform
|
||||
* syntactic validation of the expression; if in doing so it detects errors,
|
||||
* it should raise an ELParseException.
|
||||
*
|
||||
* @param expression
|
||||
* The expression to be evaluated.
|
||||
* @param expectedType
|
||||
* The expected type of the result of the evaluation
|
||||
* @param fMapper
|
||||
* A FunctionMapper to resolve functions found in the expression.
|
||||
* It can be null, in which case no functions are supported for
|
||||
* this invocation. The ExpressionEvaluator must not hold on to
|
||||
* the FunctionMapper reference after returning from
|
||||
* <code>parseExpression()</code>. The <code>Expression</code>
|
||||
* object returned must invoke the same functions regardless of
|
||||
* whether the mappings in the provided
|
||||
* <code>FunctionMapper</code> instance change between calling
|
||||
* <code>ExpressionEvaluator.parseExpression()</code> and
|
||||
* <code>Expression.evaluate()</code>.
|
||||
* @return The Expression object encapsulating the arguments.
|
||||
* @exception ELException
|
||||
* Thrown if parsing errors were found.
|
||||
*/
|
||||
public abstract Expression parseExpression(String expression,
|
||||
@SuppressWarnings("rawtypes")// TCK signature fails with generics
|
||||
Class expectedType, FunctionMapper fMapper) throws ELException;
|
||||
|
||||
/**
|
||||
* Evaluates an expression. This method may perform some syntactic
|
||||
* validation and, if so, it should raise an ELParseException error if it
|
||||
* encounters syntactic errors. EL evaluation errors should cause an
|
||||
* ELException to be raised.
|
||||
*
|
||||
* @param expression
|
||||
* The expression to be evaluated.
|
||||
* @param expectedType
|
||||
* The expected type of the result of the evaluation
|
||||
* @param vResolver
|
||||
* A VariableResolver instance that can be used at runtime to
|
||||
* resolve the name of implicit objects into Objects.
|
||||
* @param fMapper
|
||||
* A FunctionMapper to resolve functions found in the expression.
|
||||
* It can be null, in which case no functions are supported for
|
||||
* this invocation.
|
||||
* @return The result of the expression evaluation.
|
||||
* @exception ELException
|
||||
* Thrown if the expression evaluation failed.
|
||||
*/
|
||||
public abstract Object evaluate(
|
||||
String expression,
|
||||
@SuppressWarnings("rawtypes")// TCK signature fails with generics
|
||||
Class expectedType, VariableResolver vResolver,
|
||||
FunctionMapper fMapper) throws ELException;
|
||||
}
|
||||
41
java/javax/servlet/jsp/el/FunctionMapper.java
Normal file
41
java/javax/servlet/jsp/el/FunctionMapper.java
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.el;
|
||||
|
||||
/**
|
||||
* <p>The interface to a map between EL function names and methods.</p>
|
||||
*
|
||||
* <p>Classes implementing this interface may, for instance, consult tag library
|
||||
* information to resolve the map. </p>
|
||||
*
|
||||
* @since 2.0
|
||||
* @deprecated As of JSP 2.1, replaced by javax.el.FunctionMapper
|
||||
*/
|
||||
@SuppressWarnings("dep-ann") // TCK signature test fails with annotation
|
||||
public interface FunctionMapper {
|
||||
/**
|
||||
* Resolves the specified local name and prefix into a Java.lang.Method.
|
||||
* Returns null if the prefix and local name are not found.
|
||||
*
|
||||
* @param prefix the prefix of the function, or "" if no prefix.
|
||||
* @param localName the short name of the function
|
||||
* @return the result of the method mapping. Null means no entry found.
|
||||
**/
|
||||
public java.lang.reflect.Method resolveFunction(String prefix,
|
||||
String localName);
|
||||
}
|
||||
609
java/javax/servlet/jsp/el/ImplicitObjectELResolver.java
Normal file
609
java/javax/servlet/jsp/el/ImplicitObjectELResolver.java
Normal file
@@ -0,0 +1,609 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.el;
|
||||
|
||||
import java.beans.FeatureDescriptor;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.el.ELContext;
|
||||
import javax.el.ELResolver;
|
||||
import javax.el.PropertyNotWritableException;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.servlet.jsp.JspContext;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public class ImplicitObjectELResolver extends ELResolver {
|
||||
|
||||
private static final String[] SCOPE_NAMES = new String[] {
|
||||
"applicationScope", "cookie", "header", "headerValues",
|
||||
"initParam", "pageContext", "pageScope", "param", "paramValues",
|
||||
"requestScope", "sessionScope" };
|
||||
|
||||
private static final int APPLICATIONSCOPE = 0;
|
||||
|
||||
private static final int COOKIE = 1;
|
||||
|
||||
private static final int HEADER = 2;
|
||||
|
||||
private static final int HEADERVALUES = 3;
|
||||
|
||||
private static final int INITPARAM = 4;
|
||||
|
||||
private static final int PAGECONTEXT = 5;
|
||||
|
||||
private static final int PAGESCOPE = 6;
|
||||
|
||||
private static final int PARAM = 7;
|
||||
|
||||
private static final int PARAM_VALUES = 8;
|
||||
|
||||
private static final int REQUEST_SCOPE = 9;
|
||||
|
||||
private static final int SESSION_SCOPE = 10;
|
||||
|
||||
public ImplicitObjectELResolver() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(ELContext context, Object base, Object property) {
|
||||
Objects.requireNonNull(context);
|
||||
|
||||
if (base == null && property != null) {
|
||||
int idx = Arrays.binarySearch(SCOPE_NAMES, property.toString());
|
||||
|
||||
if (idx >= 0) {
|
||||
PageContext page = (PageContext) context
|
||||
.getContext(JspContext.class);
|
||||
context.setPropertyResolved(base, property);
|
||||
switch (idx) {
|
||||
case APPLICATIONSCOPE:
|
||||
return ScopeManager.get(page).getApplicationScope();
|
||||
case COOKIE:
|
||||
return ScopeManager.get(page).getCookie();
|
||||
case HEADER:
|
||||
return ScopeManager.get(page).getHeader();
|
||||
case HEADERVALUES:
|
||||
return ScopeManager.get(page).getHeaderValues();
|
||||
case INITPARAM:
|
||||
return ScopeManager.get(page).getInitParam();
|
||||
case PAGECONTEXT:
|
||||
return ScopeManager.get(page).getPageContext();
|
||||
case PAGESCOPE:
|
||||
return ScopeManager.get(page).getPageScope();
|
||||
case PARAM:
|
||||
return ScopeManager.get(page).getParam();
|
||||
case PARAM_VALUES:
|
||||
return ScopeManager.get(page).getParamValues();
|
||||
case REQUEST_SCOPE:
|
||||
return ScopeManager.get(page).getRequestScope();
|
||||
case SESSION_SCOPE:
|
||||
return ScopeManager.get(page).getSessionScope();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" }) // TCK signature test fails with generics
|
||||
public Class getType(ELContext context, Object base, Object property) {
|
||||
Objects.requireNonNull(context);
|
||||
|
||||
if (base == null && property != null) {
|
||||
int idx = Arrays.binarySearch(SCOPE_NAMES, property.toString());
|
||||
if (idx >= 0) {
|
||||
context.setPropertyResolved(base, property);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(ELContext context, Object base, Object property,
|
||||
Object value) {
|
||||
Objects.requireNonNull(context);
|
||||
|
||||
if (base == null && property != null) {
|
||||
int idx = Arrays.binarySearch(SCOPE_NAMES, property.toString());
|
||||
if (idx >= 0) {
|
||||
context.setPropertyResolved(base, property);
|
||||
throw new PropertyNotWritableException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadOnly(ELContext context, Object base, Object property) {
|
||||
Objects.requireNonNull(context);
|
||||
|
||||
if (base == null && property != null) {
|
||||
int idx = Arrays.binarySearch(SCOPE_NAMES, property.toString());
|
||||
if (idx >= 0) {
|
||||
context.setPropertyResolved(base, property);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
|
||||
List<FeatureDescriptor> feats = new ArrayList<>(SCOPE_NAMES.length);
|
||||
FeatureDescriptor feat;
|
||||
for (int i = 0; i < SCOPE_NAMES.length; i++) {
|
||||
feat = new FeatureDescriptor();
|
||||
feat.setDisplayName(SCOPE_NAMES[i]);
|
||||
feat.setExpert(false);
|
||||
feat.setHidden(false);
|
||||
feat.setName(SCOPE_NAMES[i]);
|
||||
feat.setPreferred(true);
|
||||
feat.setValue(RESOLVABLE_AT_DESIGN_TIME, Boolean.TRUE);
|
||||
feat.setValue(TYPE, String.class);
|
||||
feats.add(feat);
|
||||
}
|
||||
return feats.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<String> getCommonPropertyType(ELContext context, Object base) {
|
||||
if (base == null) {
|
||||
return String.class;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static class ScopeManager {
|
||||
private static final String MNGR_KEY = ScopeManager.class.getName();
|
||||
|
||||
private final PageContext page;
|
||||
|
||||
private Map<String,Object> applicationScope;
|
||||
|
||||
private Map<String,Cookie> cookie;
|
||||
|
||||
private Map<String,String> header;
|
||||
|
||||
private Map<String,String[]> headerValues;
|
||||
|
||||
private Map<String,String> initParam;
|
||||
|
||||
private Map<String,Object> pageScope;
|
||||
|
||||
private Map<String,String> param;
|
||||
|
||||
private Map<String,String[]> paramValues;
|
||||
|
||||
private Map<String,Object> requestScope;
|
||||
|
||||
private Map<String,Object> sessionScope;
|
||||
|
||||
public ScopeManager(PageContext page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public static ScopeManager get(PageContext page) {
|
||||
ScopeManager mngr = (ScopeManager) page.getAttribute(MNGR_KEY);
|
||||
if (mngr == null) {
|
||||
mngr = new ScopeManager(page);
|
||||
page.setAttribute(MNGR_KEY, mngr);
|
||||
}
|
||||
return mngr;
|
||||
}
|
||||
|
||||
public Map<String,Object> getApplicationScope() {
|
||||
if (this.applicationScope == null) {
|
||||
this.applicationScope = new ScopeMap<Object>() {
|
||||
@Override
|
||||
protected void setAttribute(String name, Object value) {
|
||||
page.getServletContext().setAttribute(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void removeAttribute(String name) {
|
||||
page.getServletContext().removeAttribute(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Enumeration<String> getAttributeNames() {
|
||||
return page.getServletContext().getAttributeNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getAttribute(String name) {
|
||||
return page.getServletContext().getAttribute(name);
|
||||
}
|
||||
};
|
||||
}
|
||||
return this.applicationScope;
|
||||
}
|
||||
|
||||
public Map<String,Cookie> getCookie() {
|
||||
if (this.cookie == null) {
|
||||
this.cookie = new ScopeMap<Cookie>() {
|
||||
@Override
|
||||
protected Enumeration<String> getAttributeNames() {
|
||||
Cookie[] c = ((HttpServletRequest) page.getRequest())
|
||||
.getCookies();
|
||||
if (c != null) {
|
||||
Vector<String> v = new Vector<>();
|
||||
for (int i = 0; i < c.length; i++) {
|
||||
v.add(c[i].getName());
|
||||
}
|
||||
return v.elements();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Cookie getAttribute(String name) {
|
||||
Cookie[] c = ((HttpServletRequest) page.getRequest())
|
||||
.getCookies();
|
||||
if (c != null) {
|
||||
for (int i = 0; i < c.length; i++) {
|
||||
if (name.equals(c[i].getName())) {
|
||||
return c[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
return this.cookie;
|
||||
}
|
||||
|
||||
public Map<String,String> getHeader() {
|
||||
if (this.header == null) {
|
||||
this.header = new ScopeMap<String>() {
|
||||
@Override
|
||||
protected Enumeration<String> getAttributeNames() {
|
||||
return ((HttpServletRequest) page.getRequest())
|
||||
.getHeaderNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getAttribute(String name) {
|
||||
return ((HttpServletRequest) page.getRequest())
|
||||
.getHeader(name);
|
||||
}
|
||||
};
|
||||
}
|
||||
return this.header;
|
||||
}
|
||||
|
||||
public Map<String,String[]> getHeaderValues() {
|
||||
if (this.headerValues == null) {
|
||||
this.headerValues = new ScopeMap<String[]>() {
|
||||
@Override
|
||||
protected Enumeration<String> getAttributeNames() {
|
||||
return ((HttpServletRequest) page.getRequest())
|
||||
.getHeaderNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getAttribute(String name) {
|
||||
Enumeration<String> e =
|
||||
((HttpServletRequest) page.getRequest())
|
||||
.getHeaders(name);
|
||||
if (e != null) {
|
||||
List<String> list = new ArrayList<>();
|
||||
while (e.hasMoreElements()) {
|
||||
list.add(e.nextElement());
|
||||
}
|
||||
return list.toArray(new String[list.size()]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
return this.headerValues;
|
||||
}
|
||||
|
||||
public Map<String,String> getInitParam() {
|
||||
if (this.initParam == null) {
|
||||
this.initParam = new ScopeMap<String>() {
|
||||
@Override
|
||||
protected Enumeration<String> getAttributeNames() {
|
||||
return page.getServletContext().getInitParameterNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getAttribute(String name) {
|
||||
return page.getServletContext().getInitParameter(name);
|
||||
}
|
||||
};
|
||||
}
|
||||
return this.initParam;
|
||||
}
|
||||
|
||||
public PageContext getPageContext() {
|
||||
return this.page;
|
||||
}
|
||||
|
||||
public Map<String,Object> getPageScope() {
|
||||
if (this.pageScope == null) {
|
||||
this.pageScope = new ScopeMap<Object>() {
|
||||
@Override
|
||||
protected void setAttribute(String name, Object value) {
|
||||
page.setAttribute(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void removeAttribute(String name) {
|
||||
page.removeAttribute(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Enumeration<String> getAttributeNames() {
|
||||
return page.getAttributeNamesInScope(
|
||||
PageContext.PAGE_SCOPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getAttribute(String name) {
|
||||
return page.getAttribute(name);
|
||||
}
|
||||
};
|
||||
}
|
||||
return this.pageScope;
|
||||
}
|
||||
|
||||
public Map<String,String> getParam() {
|
||||
if (this.param == null) {
|
||||
this.param = new ScopeMap<String>() {
|
||||
@Override
|
||||
protected Enumeration<String> getAttributeNames() {
|
||||
return page.getRequest().getParameterNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getAttribute(String name) {
|
||||
return page.getRequest().getParameter(name);
|
||||
}
|
||||
};
|
||||
}
|
||||
return this.param;
|
||||
}
|
||||
|
||||
public Map<String,String[]> getParamValues() {
|
||||
if (this.paramValues == null) {
|
||||
this.paramValues = new ScopeMap<String[]>() {
|
||||
@Override
|
||||
protected String[] getAttribute(String name) {
|
||||
return page.getRequest().getParameterValues(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Enumeration<String> getAttributeNames() {
|
||||
return page.getRequest().getParameterNames();
|
||||
}
|
||||
};
|
||||
}
|
||||
return this.paramValues;
|
||||
}
|
||||
|
||||
public Map<String,Object> getRequestScope() {
|
||||
if (this.requestScope == null) {
|
||||
this.requestScope = new ScopeMap<Object>() {
|
||||
@Override
|
||||
protected void setAttribute(String name, Object value) {
|
||||
page.getRequest().setAttribute(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void removeAttribute(String name) {
|
||||
page.getRequest().removeAttribute(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Enumeration<String> getAttributeNames() {
|
||||
return page.getRequest().getAttributeNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getAttribute(String name) {
|
||||
return page.getRequest().getAttribute(name);
|
||||
}
|
||||
};
|
||||
}
|
||||
return this.requestScope;
|
||||
}
|
||||
|
||||
public Map<String,Object> getSessionScope() {
|
||||
if (this.sessionScope == null) {
|
||||
this.sessionScope = new ScopeMap<Object>() {
|
||||
@Override
|
||||
protected void setAttribute(String name, Object value) {
|
||||
((HttpServletRequest) page.getRequest()).getSession()
|
||||
.setAttribute(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void removeAttribute(String name) {
|
||||
HttpSession session = page.getSession();
|
||||
if (session != null) {
|
||||
session.removeAttribute(name);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Enumeration<String> getAttributeNames() {
|
||||
HttpSession session = page.getSession();
|
||||
if (session != null) {
|
||||
return session.getAttributeNames();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getAttribute(String name) {
|
||||
HttpSession session = page.getSession();
|
||||
if (session != null) {
|
||||
return session.getAttribute(name);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
return this.sessionScope;
|
||||
}
|
||||
}
|
||||
|
||||
private abstract static class ScopeMap<V> extends AbstractMap<String,V> {
|
||||
|
||||
protected abstract Enumeration<String> getAttributeNames();
|
||||
|
||||
protected abstract V getAttribute(String name);
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
protected void removeAttribute(String name) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
protected void setAttribute(String name, Object value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Set<Map.Entry<String,V>> entrySet() {
|
||||
Enumeration<String> e = getAttributeNames();
|
||||
Set<Map.Entry<String, V>> set = new HashSet<>();
|
||||
if (e != null) {
|
||||
while (e.hasMoreElements()) {
|
||||
set.add(new ScopeEntry(e.nextElement()));
|
||||
}
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int size() {
|
||||
int size = 0;
|
||||
Enumeration<String> e = getAttributeNames();
|
||||
if (e != null) {
|
||||
while (e.hasMoreElements()) {
|
||||
e.nextElement();
|
||||
size++;
|
||||
}
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean containsKey(Object key) {
|
||||
if (key == null) {
|
||||
return false;
|
||||
}
|
||||
Enumeration<String> e = getAttributeNames();
|
||||
if (e != null) {
|
||||
while (e.hasMoreElements()) {
|
||||
if (key.equals(e.nextElement())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private class ScopeEntry implements Map.Entry<String,V> {
|
||||
|
||||
private final String key;
|
||||
|
||||
public ScopeEntry(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public V getValue() {
|
||||
return getAttribute(this.key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V setValue(Object value) {
|
||||
if (value == null) {
|
||||
removeAttribute(this.key);
|
||||
} else {
|
||||
setAttribute(this.key, value);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (obj != null && this.hashCode() == obj.hashCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.key.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public final V get(Object key) {
|
||||
if (key != null) {
|
||||
return getAttribute((String) key);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final V put(String key, V value) {
|
||||
Objects.requireNonNull(key);
|
||||
if (value == null) {
|
||||
this.removeAttribute(key);
|
||||
} else {
|
||||
this.setAttribute(key, value);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final V remove(Object key) {
|
||||
Objects.requireNonNull(key);
|
||||
this.removeAttribute((String) key);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
238
java/javax/servlet/jsp/el/ScopedAttributeELResolver.java
Normal file
238
java/javax/servlet/jsp/el/ScopedAttributeELResolver.java
Normal file
@@ -0,0 +1,238 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.el;
|
||||
|
||||
import java.beans.FeatureDescriptor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.el.ELClass;
|
||||
import javax.el.ELContext;
|
||||
import javax.el.ELResolver;
|
||||
import javax.el.ImportHandler;
|
||||
import javax.servlet.jsp.JspContext;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public class ScopedAttributeELResolver extends ELResolver {
|
||||
|
||||
// Indicates if a performance short-cut is available
|
||||
private static final Class<?> AST_IDENTIFIER_KEY;
|
||||
|
||||
static {
|
||||
Class<?> key = null;
|
||||
try {
|
||||
key = Class.forName("org.apache.el.parser.AstIdentifier");
|
||||
} catch (Exception e) {
|
||||
// Ignore: Expected if not running on Tomcat. Not a problem since
|
||||
// this just allows a short-cut.
|
||||
}
|
||||
AST_IDENTIFIER_KEY = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(ELContext context, Object base, Object property) {
|
||||
Objects.requireNonNull(context);
|
||||
|
||||
Object result = null;
|
||||
|
||||
if (base == null) {
|
||||
context.setPropertyResolved(base, property);
|
||||
if (property != null) {
|
||||
String key = property.toString();
|
||||
PageContext page = (PageContext) context.getContext(JspContext.class);
|
||||
result = page.findAttribute(key);
|
||||
|
||||
if (result == null) {
|
||||
boolean resolveClass = true;
|
||||
// Performance short-cut available when running on Tomcat
|
||||
if (AST_IDENTIFIER_KEY != null) {
|
||||
// Tomcat will set this key to Boolean.TRUE if the
|
||||
// identifier is a stand-alone identifier (i.e.
|
||||
// identifier) rather than part of an AstValue (i.e.
|
||||
// identifier.something). Imports do not need to be
|
||||
// checked if this is a stand-alone identifier
|
||||
Boolean value = (Boolean) context.getContext(AST_IDENTIFIER_KEY);
|
||||
if (value != null && value.booleanValue()) {
|
||||
resolveClass = false;
|
||||
}
|
||||
}
|
||||
// This might be the name of an imported class
|
||||
ImportHandler importHandler = context.getImportHandler();
|
||||
if (importHandler != null) {
|
||||
Class<?> clazz = null;
|
||||
if (resolveClass) {
|
||||
clazz = importHandler.resolveClass(key);
|
||||
}
|
||||
if (clazz != null) {
|
||||
result = new ELClass(clazz);
|
||||
}
|
||||
if (result == null) {
|
||||
// This might be the name of an imported static field
|
||||
clazz = importHandler.resolveStatic(key);
|
||||
if (clazz != null) {
|
||||
try {
|
||||
result = clazz.getField(key).get(null);
|
||||
} catch (IllegalArgumentException | IllegalAccessException |
|
||||
NoSuchFieldException | SecurityException e) {
|
||||
// Most (all?) of these should have been
|
||||
// prevented by the checks when the import
|
||||
// was defined.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<Object> getType(ELContext context, Object base, Object property) {
|
||||
Objects.requireNonNull(context);
|
||||
|
||||
if (base == null) {
|
||||
context.setPropertyResolved(base, property);
|
||||
return Object.class;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(ELContext context, Object base, Object property, Object value) {
|
||||
Objects.requireNonNull(context);
|
||||
|
||||
if (base == null) {
|
||||
context.setPropertyResolved(base, property);
|
||||
if (property != null) {
|
||||
String key = property.toString();
|
||||
PageContext page = (PageContext) context.getContext(JspContext.class);
|
||||
int scope = page.getAttributesScope(key);
|
||||
if (scope != 0) {
|
||||
page.setAttribute(key, value, scope);
|
||||
} else {
|
||||
page.setAttribute(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadOnly(ELContext context, Object base, Object property) {
|
||||
Objects.requireNonNull(context);
|
||||
|
||||
if (base == null) {
|
||||
context.setPropertyResolved(base, property);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
|
||||
|
||||
PageContext ctxt = (PageContext) context.getContext(JspContext.class);
|
||||
List<FeatureDescriptor> list = new ArrayList<>();
|
||||
Enumeration<String> e;
|
||||
Object value;
|
||||
String name;
|
||||
|
||||
e = ctxt.getAttributeNamesInScope(PageContext.PAGE_SCOPE);
|
||||
while (e.hasMoreElements()) {
|
||||
name = e.nextElement();
|
||||
value = ctxt.getAttribute(name, PageContext.PAGE_SCOPE);
|
||||
FeatureDescriptor descriptor = new FeatureDescriptor();
|
||||
descriptor.setName(name);
|
||||
descriptor.setDisplayName(name);
|
||||
descriptor.setExpert(false);
|
||||
descriptor.setHidden(false);
|
||||
descriptor.setPreferred(true);
|
||||
descriptor.setShortDescription("page scoped attribute");
|
||||
descriptor.setValue("type", value.getClass());
|
||||
descriptor.setValue("resolvableAtDesignTime", Boolean.FALSE);
|
||||
list.add(descriptor);
|
||||
}
|
||||
|
||||
e = ctxt.getAttributeNamesInScope(PageContext.REQUEST_SCOPE);
|
||||
while (e.hasMoreElements()) {
|
||||
name = e.nextElement();
|
||||
value = ctxt.getAttribute(name, PageContext.REQUEST_SCOPE);
|
||||
FeatureDescriptor descriptor = new FeatureDescriptor();
|
||||
descriptor.setName(name);
|
||||
descriptor.setDisplayName(name);
|
||||
descriptor.setExpert(false);
|
||||
descriptor.setHidden(false);
|
||||
descriptor.setPreferred(true);
|
||||
descriptor.setShortDescription("request scope attribute");
|
||||
descriptor.setValue("type", value.getClass());
|
||||
descriptor.setValue("resolvableAtDesignTime", Boolean.FALSE);
|
||||
list.add(descriptor);
|
||||
}
|
||||
|
||||
if (ctxt.getSession() != null) {
|
||||
e = ctxt.getAttributeNamesInScope(PageContext.SESSION_SCOPE);
|
||||
while (e.hasMoreElements()) {
|
||||
name = e.nextElement();
|
||||
value = ctxt.getAttribute(name, PageContext.SESSION_SCOPE);
|
||||
FeatureDescriptor descriptor = new FeatureDescriptor();
|
||||
descriptor.setName(name);
|
||||
descriptor.setDisplayName(name);
|
||||
descriptor.setExpert(false);
|
||||
descriptor.setHidden(false);
|
||||
descriptor.setPreferred(true);
|
||||
descriptor.setShortDescription("session scoped attribute");
|
||||
descriptor.setValue("type", value.getClass());
|
||||
descriptor.setValue("resolvableAtDesignTime", Boolean.FALSE);
|
||||
list.add(descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
e = ctxt.getAttributeNamesInScope(PageContext.APPLICATION_SCOPE);
|
||||
while (e.hasMoreElements()) {
|
||||
name = e.nextElement();
|
||||
value = ctxt.getAttribute(name, PageContext.APPLICATION_SCOPE);
|
||||
FeatureDescriptor descriptor = new FeatureDescriptor();
|
||||
descriptor.setName(name);
|
||||
descriptor.setDisplayName(name);
|
||||
descriptor.setExpert(false);
|
||||
descriptor.setHidden(false);
|
||||
descriptor.setPreferred(true);
|
||||
descriptor.setShortDescription("application scoped attribute");
|
||||
descriptor.setValue("type", value.getClass());
|
||||
descriptor.setValue("resolvableAtDesignTime", Boolean.FALSE);
|
||||
list.add(descriptor);
|
||||
}
|
||||
return list.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<String> getCommonPropertyType(ELContext context, Object base) {
|
||||
if (base == null) {
|
||||
return String.class;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
51
java/javax/servlet/jsp/el/VariableResolver.java
Normal file
51
java/javax/servlet/jsp/el/VariableResolver.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.el;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This class is used to customize the way an ExpressionEvaluator resolves
|
||||
* variable references at evaluation time. For example, instances of this class
|
||||
* can implement their own variable lookup mechanisms, or introduce the notion
|
||||
* of "implicit variables" which override any other variables. An instance of
|
||||
* this class should be passed when evaluating an expression.
|
||||
* </p>
|
||||
* <p>
|
||||
* An instance of this class includes the context against which resolution will
|
||||
* happen
|
||||
* </p>
|
||||
*
|
||||
* @since 2.0
|
||||
* @deprecated As of JSP 2.1, replaced by javax.el.ELResolver
|
||||
*/
|
||||
@SuppressWarnings("dep-ann")
|
||||
// TCK signature test fails with annotation
|
||||
public interface VariableResolver {
|
||||
|
||||
/**
|
||||
* Resolves the specified variable. Returns null if the variable is not
|
||||
* found.
|
||||
*
|
||||
* @param pName
|
||||
* the name of the variable to resolve
|
||||
* @return the result of the variable resolution
|
||||
* @throws ELException
|
||||
* if a failure occurred while trying to resolve the given
|
||||
* variable
|
||||
*/
|
||||
public Object resolveVariable(String pName) throws ELException;
|
||||
}
|
||||
37
java/javax/servlet/jsp/el/package.html
Normal file
37
java/javax/servlet/jsp/el/package.html
Normal file
@@ -0,0 +1,37 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
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
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
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.
|
||||
-->
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
Classes and interfaces for the JSP 2.0 Expression Language API.
|
||||
|
||||
<p>
|
||||
The JavaServer Pages(tm) (JSP) 2.0 specification provides a portable
|
||||
API for evaluating "EL Expressions". As of JSP 2.0, EL expressions can
|
||||
be placed directly in the template text of JSP pages and tag files.
|
||||
<p>
|
||||
This package contains a number of classes and interfaces that describe
|
||||
and define programmatic access to the Expression Language evaluator.
|
||||
This API can also be used by an implementation of JSP to evaluate the
|
||||
expressions, but other implementations, like open-coding into Java
|
||||
bytecodes, are allowed. This package is intended to have no dependencies
|
||||
on other portions of the JSP 2.0 specification.
|
||||
</body>
|
||||
</html>
|
||||
29
java/javax/servlet/jsp/package.html
Normal file
29
java/javax/servlet/jsp/package.html
Normal file
@@ -0,0 +1,29 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
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
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
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.
|
||||
-->
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
Classes and interfaces for the Core JSP 2.0 API.
|
||||
<p>
|
||||
The javax.servlet.jsp package contains a number of classes and
|
||||
interfaces that describe and define the contracts between a JSP page
|
||||
implementation class and the runtime environment provided for an
|
||||
instance of such a class by a conforming JSP container.
|
||||
</body>
|
||||
</html>
|
||||
191
java/javax/servlet/jsp/resources/jspxml.dtd
Normal file
191
java/javax/servlet/jsp/resources/jspxml.dtd
Normal file
@@ -0,0 +1,191 @@
|
||||
<!--
|
||||
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
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
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.
|
||||
-->
|
||||
<!-- DTD for JSP 2.0
|
||||
thanks to Bob Foster, WebGain
|
||||
-->
|
||||
|
||||
<!--
|
||||
This DTD is not conditional on any parameter entities in the internal
|
||||
subset and does not export any general entities.
|
||||
-->
|
||||
|
||||
<!--================== Constrained Names ====================================-->
|
||||
|
||||
<!ENTITY % URI "CDATA">
|
||||
<!-- a Uniform Resource Identifier, see [RFC2396] -->
|
||||
|
||||
<!ENTITY % UriList "CDATA">
|
||||
<!-- a space separated list of Uniform Resource Identifiers -->
|
||||
|
||||
<!ENTITY % URL "CDATA">
|
||||
<!-- a relative urlSpec is as in Section 2.10.2. -->
|
||||
|
||||
<!ENTITY % BeanID "IDREF">
|
||||
<!-- a previously declared bean ID in the current scope. -->
|
||||
|
||||
<!ENTITY % Prefix "CDATA">
|
||||
<!-- a Name that contains no : characters. -->
|
||||
|
||||
<!ENTITY % ClassName "CDATA">
|
||||
<!-- a fully qualified class name. -->
|
||||
|
||||
<!ENTITY % TypeName "CDATA">
|
||||
<!-- a fully qualified class or interface name. -->
|
||||
|
||||
<!ENTITY % BeanName "CDATA">
|
||||
<!-- a bean name as expected by java.beans.Beans instantiate(). -->
|
||||
|
||||
<!ENTITY % Content "CDATA">
|
||||
<!-- a MIME type followed by an IANA charset, as " type [; S? ['charset='] charset] " -->
|
||||
|
||||
<!ENTITY % Length "CDATA">
|
||||
<!-- nn for pixels or nn% for percentage length -->
|
||||
|
||||
<!ENTITY % Pixels "CDATA">
|
||||
<!-- integer representing length in pixels -->
|
||||
|
||||
<!ENTITY % Bool "(true|false|yes|no)">
|
||||
<!-- boolean -->
|
||||
|
||||
<!-- used for object, applet, img, input and iframe -->
|
||||
<!ENTITY % ImgAlign "(top|middle|bottom|left|right)">
|
||||
|
||||
<!--=================== Element Groups ====================================-->
|
||||
|
||||
<!ENTITY % Directives "jsp:directive.page|jsp:directive.include">
|
||||
|
||||
<!ENTITY % Scripts "jsp:scriptlet|jsp:declaration|jsp:expression">
|
||||
|
||||
<!ENTITY % Actions
|
||||
"jsp:useBean
|
||||
|jsp:setProperty
|
||||
|jsp:getProperty
|
||||
|jsp:include
|
||||
|jsp:forward
|
||||
|jsp:plugin"
|
||||
>
|
||||
|
||||
<!ENTITY % Body "(jsp:text|%Directives;|%Scripts;|%Actions;)*">
|
||||
|
||||
|
||||
<!-- ============================ Elements ============================ -->
|
||||
|
||||
<!-- Root element of a JSP page.
|
||||
-->
|
||||
<!ELEMENT jsp:root %Body;>
|
||||
<!ATTLIST jsp:root
|
||||
xmlns:jsp CDATA "http://java.sun.com/JSP/Page"
|
||||
version CDATA #REQUIRED
|
||||
>
|
||||
|
||||
<!ELEMENT jsp:directive.page EMPTY>
|
||||
<!ATTLIST jsp:directive.page
|
||||
language CDATA "java"
|
||||
extends %ClassName; #IMPLIED
|
||||
contentType %Content; "text/html; charset=ISO-8859-1"
|
||||
import CDATA #IMPLIED
|
||||
session %Bool; "true"
|
||||
buffer CDATA "8kb"
|
||||
autoFlush %Bool; "true"
|
||||
isThreadSafe %Bool; "true"
|
||||
info CDATA #IMPLIED
|
||||
errorPage %URL; #IMPLIED
|
||||
isErrorPage %Bool; "false"
|
||||
pageEncoding CDATA #IMPLIED
|
||||
isELIgnored %Bool; #IMPLIED
|
||||
>
|
||||
|
||||
<!-- the jsp:directive.include only appears in JSP documents and does
|
||||
not appear in the XML views of JSP pages.
|
||||
-->
|
||||
|
||||
<!ELEMENT jsp:directive.include EMPTY>
|
||||
<!ATTLIST jsp:directive.include
|
||||
file %URI; #REQUIRED
|
||||
>
|
||||
|
||||
<!ELEMENT jsp:scriptlet (#PCDATA)>
|
||||
|
||||
<!ELEMENT jsp:declaration (#PCDATA)>
|
||||
|
||||
<!ELEMENT jsp:expression (#PCDATA)>
|
||||
|
||||
<!ELEMENT jsp:useBean %Body;>
|
||||
<!ATTLIST jsp:useBean
|
||||
id ID #REQUIRED
|
||||
class %ClassName; #IMPLIED
|
||||
type %TypeName; #IMPLIED
|
||||
beanName %BeanName; #IMPLIED
|
||||
scope (page
|
||||
|session
|
||||
|request
|
||||
|application) "page"
|
||||
>
|
||||
|
||||
<!ELEMENT jsp:setProperty EMPTY>
|
||||
<!ATTLIST jsp:setProperty
|
||||
name %BeanID; #REQUIRED
|
||||
property CDATA #REQUIRED
|
||||
value CDATA #IMPLIED
|
||||
param CDATA #IMPLIED
|
||||
>
|
||||
|
||||
<!ELEMENT jsp:getProperty EMPTY>
|
||||
<!ATTLIST jsp:getProperty
|
||||
name %BeanID; #REQUIRED
|
||||
property CDATA #REQUIRED
|
||||
>
|
||||
|
||||
<!ELEMENT jsp:include (jsp:param*)>
|
||||
<!ATTLIST jsp:include
|
||||
flush %Bool; "false"
|
||||
page %URL; #REQUIRED
|
||||
>
|
||||
|
||||
<!ELEMENT jsp:forward (jsp:param*)>
|
||||
<!ATTLIST jsp:forward
|
||||
page %URL; #REQUIRED
|
||||
>
|
||||
|
||||
<!ELEMENT jsp:plugin (jsp:params?, jsp:fallback?)>
|
||||
<!ATTLIST jsp:plugin
|
||||
type (bean|applet) #REQUIRED
|
||||
code %URI; #IMPLIED
|
||||
codebase %URI; #IMPLIED
|
||||
align %ImgAlign; #IMPLIED
|
||||
archive %UriList; #IMPLIED
|
||||
height %Length; #IMPLIED
|
||||
hspace %Pixels; #IMPLIED
|
||||
jreversion CDATA "1.2"
|
||||
name NMTOKEN #IMPLIED
|
||||
vspace %Pixels; #IMPLIED
|
||||
width %Length; #IMPLIED
|
||||
nspluginurl %URI; #IMPLIED
|
||||
iepluginurl %URI; #IMPLIED
|
||||
>
|
||||
|
||||
<!ELEMENT jsp:params (jsp:param+)>
|
||||
|
||||
<!ELEMENT jsp:param EMPTY>
|
||||
<!ATTLIST jsp:param
|
||||
name CDATA #REQUIRED
|
||||
value CDATA #REQUIRED
|
||||
>
|
||||
|
||||
<!ELEMENT jsp:text (#PCDATA)>
|
||||
|
||||
<!ELEMENT jsp:fallback %Body;>
|
||||
514
java/javax/servlet/jsp/resources/jspxml.xsd
Normal file
514
java/javax/servlet/jsp/resources/jspxml.xsd
Normal file
@@ -0,0 +1,514 @@
|
||||
<?xml version ="1.0"?>
|
||||
<!--
|
||||
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
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
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.
|
||||
-->
|
||||
<!DOCTYPE schema [
|
||||
<!-- Patterns -->
|
||||
<!ENTITY Identifier "(\p{L}|_|$)(\p{N}|\p{L}|_|$)*">
|
||||
<!ENTITY TypeName "&Identifier;(\.&Identifier;)*">
|
||||
<!ENTITY WS "\s*">
|
||||
<!ENTITY Import "&TypeName;(\.\*)?">
|
||||
<!ENTITY ImportList "&Import;(&WS;,&WS;&Import;)*">
|
||||
<!ENTITY SetProp "(&Identifier;|\*)">
|
||||
<!ENTITY RelativeURL "[^:#/\?]*(:{0,0}|[#/\?].*)">
|
||||
<!ENTITY Length "[0-9]*%?">
|
||||
<!ENTITY AsciiName "[A-Za-z0-9_-]*">
|
||||
<!ENTITY ValidContentType "&AsciiName;/&AsciiName;(;&WS;(charset=)?&AsciiName;)?">
|
||||
<!ENTITY ValidPageEncoding "&AsciiName;/&AsciiName;">
|
||||
<!ENTITY Buffer "[0-9]+kb">
|
||||
<!ENTITY RTexpr "%=.*%">
|
||||
]>
|
||||
|
||||
|
||||
<!--Conforms to w3c http://www.w3.org/2001/XMLSchema -->
|
||||
|
||||
<xsd:schema
|
||||
xmlns = "http://java.sun.com/JSP/Page"
|
||||
xmlns:xsd = "http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:jsp = "http://java.sun.com/JSP/Page"
|
||||
targetNamespace = "http://java.sun.com/JSP/Page"
|
||||
elementFormDefault = "qualified"
|
||||
attributeFormDefault = "unqualified">
|
||||
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
XML Schema for JSP 2.0.
|
||||
|
||||
This schema is based upon the recent (May 5th, 2001)
|
||||
W3C recommendation for XML Schema.
|
||||
|
||||
A JSP translator should reject an XML-format file that is
|
||||
not strictly valid according to this schema or does not observe
|
||||
the constraints documented here. A translator is not required
|
||||
to use this schema for validation or to use a validating parser.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
|
||||
|
||||
<!-- Complex Types -->
|
||||
|
||||
<xsd:complexType name = "Body">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Body defines the "top-level" elements in root and beanInfo.
|
||||
There are probably other elements that should use it.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:group ref = "Bodygroup" minOccurs = "0" maxOccurs = "unbounded"/>
|
||||
</xsd:complexType>
|
||||
|
||||
<!-- groups -->
|
||||
|
||||
<xsd:group name = "Bodygroup">
|
||||
<xsd:choice>
|
||||
<xsd:element ref = "directive.page"/>
|
||||
<xsd:element ref = "directive.include"/>
|
||||
<xsd:element ref = "scriptlet"/>
|
||||
<xsd:element ref = "declaration"/>
|
||||
<xsd:element ref = "expression"/>
|
||||
<xsd:element ref = "useBean"/>
|
||||
<xsd:element ref = "setProperty"/>
|
||||
<xsd:element ref = "getProperty"/>
|
||||
<xsd:element ref = "include"/>
|
||||
<xsd:element ref = "forward"/>
|
||||
<xsd:element ref = "plugin"/>
|
||||
<xsd:element ref = "text"/>
|
||||
<xsd:any namespace="##other" processContents = "lax"/>
|
||||
</xsd:choice>
|
||||
</xsd:group>
|
||||
|
||||
|
||||
<!-- Simple types are next -->
|
||||
|
||||
<xsd:simpleType name = "RTE">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
A request-time expression value
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:restriction base = "xsd:string">
|
||||
<xsd:pattern value = "&RTexpr;"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
<xsd:simpleType name = "Bool">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Bool would be boolean except it does not accept 1 and 0.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:restriction base = "xsd:NMTOKEN" >
|
||||
<xsd:enumeration value = "true"/>
|
||||
<xsd:enumeration value = "false"/>
|
||||
<xsd:enumeration value = "yes"/>
|
||||
<xsd:enumeration value = "no"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
<xsd:simpleType name = "Identifier">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Identifier is an unqualified Java identifier.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:restriction base = "xsd:string">
|
||||
<xsd:pattern value = "&Identifier;"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
<xsd:simpleType name = "TypeName">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
TypeName is one or more Java identifiers separated by dots
|
||||
with no whitespace.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:restriction base = "xsd:string">
|
||||
<xsd:pattern value = "&TypeName;"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
<xsd:simpleType name = "ImportList">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
ImportList is one or more typeNames separated by commas.
|
||||
Whitespace is allowed before and after the comma.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:restriction base = "xsd:string">
|
||||
<xsd:pattern value = "&ImportList;"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
<xsd:simpleType name = "SetProp">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
SetProp is an Identifier or *.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:restriction base = "xsd:string">
|
||||
<xsd:pattern value = "&SetProp;"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
<xsd:simpleType name = "RelativeURL">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
RelativeURL is a uriReference with no colon character
|
||||
before the first /, ? or #, if any (RFC2396).
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:restriction base = "xsd:anyURI">
|
||||
<xsd:pattern value = "&RelativeURL;"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
<xsd:simpleType name = "RTERelativeURL">
|
||||
<xsd:union memberTypes = "RelativeURL RTE"/>
|
||||
</xsd:simpleType>
|
||||
|
||||
<xsd:simpleType name = "Length">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Length is nn or nn%.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:restriction base = "xsd:string">
|
||||
<xsd:pattern value = "&Length;"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
|
||||
<xsd:simpleType name = "ExplicitBufferSize">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Buffer Size with an explicit value
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:restriction base = "xsd:string">
|
||||
<xsd:pattern value = "&Buffer;"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
<xsd:simpleType name = "NoneBufferSize">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Buffer Size with a "none" value
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:restriction base = "xsd:string">
|
||||
<xsd:enumeration value = "none"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
<xsd:simpleType name = "BufferSize">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Buffer size is xkb or none.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:union memberTypes = "ExplicitBufferSize NoneBufferSize"/>
|
||||
</xsd:simpleType>
|
||||
|
||||
<xsd:simpleType name = "ContentType">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Content type and character encoding for this page.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:restriction base = "xsd:string">
|
||||
<xsd:pattern value = "&ValidContentType;"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
<xsd:simpleType name = "PageEncoding">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Page Encoding for this page.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:restriction base = "xsd:string">
|
||||
<xsd:pattern value = "&ValidPageEncoding;"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
<xsd:simpleType name = "Scope">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
valid scope values
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:restriction base = "xsd:NMTOKEN">
|
||||
<xsd:enumeration value = "page"/>
|
||||
<xsd:enumeration value = "session"/>
|
||||
<xsd:enumeration value = "request"/>
|
||||
<xsd:enumeration value = "application"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
<xsd:simpleType name = "PlugInType">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
valid values for a plugin type
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:restriction base = "xsd:NMTOKEN">
|
||||
<xsd:enumeration value = "bean"/>
|
||||
<xsd:enumeration value = "applet"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
<xsd:simpleType name = "AlignType">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Buffer size is xkb.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:restriction base = "xsd:NMTOKEN">
|
||||
<xsd:enumeration value = "top"/>
|
||||
<xsd:enumeration value = "middle"/>
|
||||
<xsd:enumeration value = "bottom"/>
|
||||
<xsd:enumeration value = "left"/>
|
||||
<xsd:enumeration value = "right"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
<!-- Elements follow -->
|
||||
|
||||
<xsd:element name = "root">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
The root element of all JSP documents is named root.
|
||||
|
||||
Authors may, if they wish, include schema location information.
|
||||
If specified, the information may appear as attributes of
|
||||
the root element as follows:
|
||||
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/JSP/Page xsd-file-location"
|
||||
|
||||
Documents should not specify the system identifier of a DTD
|
||||
in a DOCTYPE declaration.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base = "Body">
|
||||
<xsd:attribute name = "version" fixed = "2.0" type = "xsd:string"/>
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name = "directive.page">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
directive.page is the "page directive".
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name = "language" default = "java" type = "xsd:string"/>
|
||||
<xsd:attribute name = "extends" type = "TypeName"/>
|
||||
<xsd:attribute name = "contentType" default = "text/html; charset=ISO-8859-1" type = "ContentType"/>
|
||||
<xsd:attribute name = "pageEncoding" use = "optional" type = "PageEncoding"/>
|
||||
<xsd:attribute name = "import" type = "ImportList"/>
|
||||
<xsd:attribute name = "session" default = "true" type = "Bool"/>
|
||||
<xsd:attribute name = "buffer" default = "8kb" type = "BufferSize"/>
|
||||
<xsd:attribute name = "autoFlush" default = "true" type = "Bool"/>
|
||||
<xsd:attribute name = "isThreadSafe" default = "true" type = "Bool"/>
|
||||
<xsd:attribute name = "info" type = "xsd:string"/>
|
||||
<xsd:attribute name = "errorPage" type = "RelativeURL"/>
|
||||
<xsd:attribute name = "isErrorPage" default = "false" type = "Bool"/>
|
||||
<xsd:attribute name = "isELIgnored" type = "Bool"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name = "directive.include">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
directive.include is the "include directive".
|
||||
This element does not appear on XML views of JSP pages.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name = "file" use = "required" type = "RelativeURL"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name = "scriptlet" type = "xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
The representation of a scriplet.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name = "declaration" type = "xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
The representation of a declaration.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name = "expression" type = "xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
The representation of an expression.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name = "text" type = "xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Verbatim template text.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name = "useBean">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
useBean instantiates or accesses a bean in the specified scope.
|
||||
|
||||
Constraint: The allowed combinations of attributes are:
|
||||
|
||||
class [type] | type [( class | beanName)]
|
||||
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="Body">
|
||||
<xsd:attribute name = "id" use = "required" type = "Identifier"/>
|
||||
<xsd:attribute name = "class" type = "TypeName"/>
|
||||
<xsd:attribute name = "type" type = "TypeName"/>
|
||||
<xsd:attribute name = "beanName" type = "TypeName"/>
|
||||
<xsd:attribute name = "scope" default = "page" type = "Scope"/>
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name = "setProperty">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
setProperty changes the value of an object property.
|
||||
|
||||
Constraint: The object named by the name must have been
|
||||
"introduced" to the JSP processor using either the
|
||||
jsp:useBean action or a custom action with an associated
|
||||
VariableInfo entry for this name.
|
||||
|
||||
Exact valid combinations are not expressable in XML Schema.
|
||||
They are:
|
||||
|
||||
name="Identifier" property="*"
|
||||
name="Identifier" property="Identfiier" param="string"
|
||||
name="Identifier" property="Identifier" value="string"
|
||||
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name = "name" use = "required" type = "Identifier"/>
|
||||
<xsd:attribute name = "property" use = "required" type = "SetProp"/>
|
||||
<xsd:attribute name = "param" type = "xsd:string"/>
|
||||
<xsd:attribute name = "value" type = "xsd:string"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name = "getProperty">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
getProperty obtains the value of an object property.
|
||||
|
||||
Constraint: The object named by the name must have been
|
||||
"introduced" to the JSP processor using either the
|
||||
jsp:useBean action or a custom action with an associated
|
||||
VariableInfo entry for this name.
|
||||
|
||||
???The spec is interpreted as restricting the values of
|
||||
property to Identifier.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name = "name" use = "required" type = "Identifier"/>
|
||||
<xsd:attribute name = "property" use = "required" type = "Identifier"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name = "include">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element ref = "param" minOccurs = "0" maxOccurs = "unbounded"/>
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name = "flush" default = "false" type = "Bool"/>
|
||||
<xsd:attribute name = "page" use = "required" type = "RTERelativeURL"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name = "forward">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element ref = "param" minOccurs = "0" maxOccurs = "unbounded"/>
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name = "page" use = "required" type = "RTERelativeURL"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name = "plugin">
|
||||
<xsd:complexType> <!-- content only! -->
|
||||
<xsd:sequence>
|
||||
<xsd:element ref = "params" minOccurs = "0" maxOccurs = "1"/>
|
||||
<xsd:element name = "fallback" minOccurs = "0" maxOccurs = "1" type = "Body"/>
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name = "type" use = "required" type = "PlugInType"/>
|
||||
<xsd:attribute name = "code" type = "xsd:anyURI"/>
|
||||
<xsd:attribute name = "codebase" type = "xsd:anyURI"/>
|
||||
<xsd:attribute name = "align" type = "AlignType"/>
|
||||
<xsd:attribute name = "archive">
|
||||
<xsd:simpleType>
|
||||
<xsd:list itemType="xsd:anyURI"/>
|
||||
</xsd:simpleType>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name = "height" type = "Length"/>
|
||||
<xsd:attribute name = "hspace" type = "xsd:int"/>
|
||||
<xsd:attribute name = "jreversion" default = "1.2" type = "xsd:string"/>
|
||||
<xsd:attribute name = "name" type = "xsd:NMTOKEN"/>
|
||||
<xsd:attribute name = "vspace" type = "xsd:int"/>
|
||||
<xsd:attribute name = "width" type = "Length"/>
|
||||
<xsd:attribute name = "nspluginurl" type = "xsd:anyURI"/>
|
||||
<xsd:attribute name = "iepluginurl" type = "xsd:anyURI"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name = "params">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element ref = "param" minOccurs = "1" maxOccurs = "unbounded"/>
|
||||
</xsd:sequence>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name = "param">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name = "name" use = "required" type = "xsd:NMTOKEN"/>
|
||||
<xsd:attribute name = "value" use = "required" type = "xsd:string"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
</xsd:schema>
|
||||
125
java/javax/servlet/jsp/tagext/BodyContent.java
Normal file
125
java/javax/servlet/jsp/tagext/BodyContent.java
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.tagext;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
|
||||
import javax.servlet.jsp.JspWriter;
|
||||
|
||||
/**
|
||||
* An encapsulation of the evaluation of the body of an action so it is
|
||||
* available to a tag handler. BodyContent is a subclass of JspWriter.
|
||||
* <p>
|
||||
* Note that the content of BodyContent is the result of evaluation, so it will
|
||||
* not contain actions and the like, but the result of their invocation.
|
||||
* <p>
|
||||
* BodyContent has methods to convert its contents into a String, to read its
|
||||
* contents, and to clear the contents.
|
||||
* <p>
|
||||
* The buffer size of a BodyContent object is unbounded. A BodyContent object
|
||||
* cannot be in autoFlush mode. It is not possible to invoke flush on a
|
||||
* BodyContent object, as there is no backing stream.
|
||||
* <p>
|
||||
* Instances of BodyContent are created by invoking the pushBody and popBody
|
||||
* methods of the PageContext class. A BodyContent is enclosed within another
|
||||
* JspWriter (maybe another BodyContent object) following the structure of their
|
||||
* associated actions.
|
||||
* <p>
|
||||
* A BodyContent is made available to a BodyTag through a setBodyContent() call.
|
||||
* The tag handler can use the object until after the call to doEndTag().
|
||||
*/
|
||||
public abstract class BodyContent extends JspWriter {
|
||||
|
||||
/**
|
||||
* Protected constructor. Unbounded buffer, no autoflushing.
|
||||
*
|
||||
* @param e
|
||||
* the enclosing JspWriter
|
||||
*/
|
||||
protected BodyContent(JspWriter e) {
|
||||
super(UNBOUNDED_BUFFER, false);
|
||||
this.enclosingWriter = e;
|
||||
}
|
||||
|
||||
/**
|
||||
* Redefined flush() so it is not legal.
|
||||
* <p>
|
||||
* It is not valid to flush a BodyContent because there is no backing stream
|
||||
* behind it.
|
||||
*
|
||||
* @throws IOException
|
||||
* always thrown
|
||||
*/
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
throw new IOException("Illegal to flush within a custom tag");
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the body without throwing any exceptions.
|
||||
*/
|
||||
public void clearBody() {
|
||||
try {
|
||||
this.clear();
|
||||
} catch (IOException ex) {
|
||||
// TODO -- clean this one up.
|
||||
throw new Error("internal error!;");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of this BodyContent as a Reader.
|
||||
*
|
||||
* @return the value of this BodyContent as a Reader
|
||||
*/
|
||||
public abstract Reader getReader();
|
||||
|
||||
/**
|
||||
* Return the value of the BodyContent as a String.
|
||||
*
|
||||
* @return the value of the BodyContent as a String
|
||||
*/
|
||||
public abstract String getString();
|
||||
|
||||
/**
|
||||
* Write the contents of this BodyContent into a Writer. Subclasses may
|
||||
* optimize common invocation patterns.
|
||||
*
|
||||
* @param out
|
||||
* The writer into which to place the contents of this body
|
||||
* evaluation
|
||||
* @throws IOException
|
||||
* if an I/O error occurred while writing the contents of this
|
||||
* BodyContent to the given Writer
|
||||
*/
|
||||
public abstract void writeOut(Writer out) throws IOException;
|
||||
|
||||
/**
|
||||
* Get the enclosing JspWriter.
|
||||
*
|
||||
* @return the enclosing JspWriter passed at construction time
|
||||
*/
|
||||
public JspWriter getEnclosingWriter() {
|
||||
return enclosingWriter;
|
||||
}
|
||||
|
||||
// private fields
|
||||
|
||||
private final JspWriter enclosingWriter;
|
||||
}
|
||||
162
java/javax/servlet/jsp/tagext/BodyTag.java
Normal file
162
java/javax/servlet/jsp/tagext/BodyTag.java
Normal file
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.tagext;
|
||||
|
||||
import javax.servlet.jsp.JspException;
|
||||
|
||||
|
||||
/**
|
||||
* The BodyTag interface extends IterationTag by defining additional methods
|
||||
* that let a tag handler manipulate the content of evaluating its body.
|
||||
* <p>
|
||||
* It is the responsibility of the tag handler to manipulate the body content.
|
||||
* For example the tag handler may take the body content, convert it into a
|
||||
* String using the bodyContent.getString method and then use it. Or the tag
|
||||
* handler may take the body content and write it out into its enclosing
|
||||
* JspWriter using the bodyContent.writeOut method.
|
||||
* <p>
|
||||
* A tag handler that implements BodyTag is treated as one that implements
|
||||
* IterationTag, except that the doStartTag method can return SKIP_BODY,
|
||||
* EVAL_BODY_INCLUDE or EVAL_BODY_BUFFERED.
|
||||
* <p>
|
||||
* If EVAL_BODY_INCLUDE is returned, then evaluation happens as in IterationTag.
|
||||
* <p>
|
||||
* If EVAL_BODY_BUFFERED is returned, then a BodyContent object will be created
|
||||
* (by code generated by the JSP compiler) to capture the body evaluation. The
|
||||
* code generated by the JSP compiler obtains the BodyContent object by calling
|
||||
* the pushBody method of the current pageContext, which additionally has the
|
||||
* effect of saving the previous out value. The page compiler returns this
|
||||
* object by calling the popBody method of the PageContext class; the call also
|
||||
* restores the value of out.
|
||||
* <p>
|
||||
* The interface provides one new property with a setter method and one new
|
||||
* action method.
|
||||
* <p>
|
||||
* <B>Properties</B>
|
||||
* <p>
|
||||
* There is a new property: bodyContent, to contain the BodyContent object,
|
||||
* where the JSP Page implementation object will place the evaluation (and
|
||||
* reevaluation, if appropriate) of the body. The setter method (setBodyContent)
|
||||
* will only be invoked if doStartTag() returns EVAL_BODY_BUFFERED and the
|
||||
* corresponding action element does not have an empty body.
|
||||
* <p>
|
||||
* <B>Methods</B>
|
||||
* <p>
|
||||
* In addition to the setter method for the bodyContent property, there is a new
|
||||
* action method: doInitBody(), which is invoked right after setBodyContent()
|
||||
* and before the body evaluation. This method is only invoked if doStartTag()
|
||||
* returns EVAL_BODY_BUFFERED.
|
||||
* <p>
|
||||
* <B>Lifecycle</B>
|
||||
* <p>
|
||||
* Lifecycle details are described by the transition diagram below. Exceptions
|
||||
* that are thrown during the computation of doStartTag(), setBodyContent(),
|
||||
* doInitBody(), BODY, doAfterBody() interrupt the execution sequence and are
|
||||
* propagated up the stack, unless the tag handler implements the
|
||||
* TryCatchFinally interface; see that interface for details.
|
||||
* <p>
|
||||
* <IMG src="doc-files/BodyTagProtocol.gif"
|
||||
* alt="Lifecycle Details Transition Diagram for BodyTag">
|
||||
* <p>
|
||||
* <B>Empty and Non-Empty Action</B>
|
||||
* <p>
|
||||
* If the TagLibraryDescriptor file indicates that the action must always have
|
||||
* an empty element body, by an <body-content> entry of "empty", then the
|
||||
* doStartTag() method must return SKIP_BODY. Otherwise, the doStartTag() method
|
||||
* may return SKIP_BODY, EVAL_BODY_INCLUDE, or EVAL_BODY_BUFFERED.
|
||||
* <p>
|
||||
* Note that which methods are invoked after the doStartTag() depends on both
|
||||
* the return value and on if the custom action element is empty or not in the
|
||||
* JSP page, not how it's declared in the TLD.
|
||||
* <p>
|
||||
* If SKIP_BODY is returned the body is not evaluated, and doEndTag() is
|
||||
* invoked.
|
||||
* <p>
|
||||
* If EVAL_BODY_INCLUDE is returned, and the custom action element is not empty,
|
||||
* setBodyContent() is not invoked, doInitBody() is not invoked, the body is
|
||||
* evaluated and "passed through" to the current out, doAfterBody() is invoked
|
||||
* and then, after zero or more iterations, doEndTag() is invoked. If the custom
|
||||
* action element is empty, only doStart() and doEndTag() are invoked.
|
||||
* <p>
|
||||
* If EVAL_BODY_BUFFERED is returned, and the custom action element is not
|
||||
* empty, setBodyContent() is invoked, doInitBody() is invoked, the body is
|
||||
* evaluated, doAfterBody() is invoked, and then, after zero or more iterations,
|
||||
* doEndTag() is invoked. If the custom action element is empty, only doStart()
|
||||
* and doEndTag() are invoked.
|
||||
*/
|
||||
public interface BodyTag extends IterationTag {
|
||||
|
||||
/**
|
||||
* Deprecated constant that has the same value as EVAL_BODY_BUFFERED and
|
||||
* EVAL_BODY_AGAIN. This name has been marked as deprecated to encourage the
|
||||
* use of the two different terms, which are much more descriptive.
|
||||
*
|
||||
* @deprecated As of Java JSP API 1.2, use BodyTag.EVAL_BODY_BUFFERED or
|
||||
* IterationTag.EVAL_BODY_AGAIN.
|
||||
*/
|
||||
@SuppressWarnings("dep-ann")
|
||||
// TCK signature test fails with annotation
|
||||
public static final int EVAL_BODY_TAG = 2;
|
||||
|
||||
/**
|
||||
* Request the creation of new buffer, a BodyContent on which to evaluate
|
||||
* the body of this tag. Returned from doStartTag when it implements
|
||||
* BodyTag. This is an illegal return value for doStartTag when the class
|
||||
* does not implement BodyTag.
|
||||
*/
|
||||
public static final int EVAL_BODY_BUFFERED = 2;
|
||||
|
||||
/**
|
||||
* Set the bodyContent property. This method is invoked by the JSP page
|
||||
* implementation object at most once per action invocation. This method
|
||||
* will be invoked before doInitBody. This method will not be invoked for
|
||||
* empty tags or for non-empty tags whose doStartTag() method returns
|
||||
* SKIP_BODY or EVAL_BODY_INCLUDE.
|
||||
* <p>
|
||||
* When setBodyContent is invoked, the value of the implicit object out has
|
||||
* already been changed in the pageContext object. The BodyContent object
|
||||
* passed will have not data on it but may have been reused (and cleared)
|
||||
* from some previous invocation.
|
||||
* <p>
|
||||
* The BodyContent object is available and with the appropriate content
|
||||
* until after the invocation of the doEndTag method, at which case it may
|
||||
* be reused.
|
||||
*
|
||||
* @param b
|
||||
* the BodyContent
|
||||
* @see #doInitBody
|
||||
* @see #doAfterBody
|
||||
*/
|
||||
void setBodyContent(BodyContent b);
|
||||
|
||||
/**
|
||||
* Prepare for evaluation of the body. This method is invoked by the JSP
|
||||
* page implementation object after setBodyContent and before the first time
|
||||
* the body is to be evaluated. This method will not be invoked for empty
|
||||
* tags or for non-empty tags whose doStartTag() method returns SKIP_BODY or
|
||||
* EVAL_BODY_INCLUDE.
|
||||
* <p>
|
||||
* The JSP container will resynchronize the values of any AT_BEGIN and
|
||||
* NESTED variables (defined by the associated TagExtraInfo or TLD) after
|
||||
* the invocation of doInitBody().
|
||||
*
|
||||
* @throws JspException
|
||||
* if an error occurred while processing this tag
|
||||
* @see #doAfterBody
|
||||
*/
|
||||
void doInitBody() throws JspException;
|
||||
}
|
||||
153
java/javax/servlet/jsp/tagext/BodyTagSupport.java
Normal file
153
java/javax/servlet/jsp/tagext/BodyTagSupport.java
Normal file
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.tagext;
|
||||
|
||||
import javax.servlet.jsp.JspException;
|
||||
import javax.servlet.jsp.JspWriter;
|
||||
|
||||
/**
|
||||
* A base class for defining tag handlers implementing BodyTag.
|
||||
* <p>
|
||||
* The BodyTagSupport class implements the BodyTag interface and adds additional
|
||||
* convenience methods including getter methods for the bodyContent property and
|
||||
* methods to get at the previous out JspWriter.
|
||||
* <p>
|
||||
* Many tag handlers will extend BodyTagSupport and only redefine a few methods.
|
||||
*/
|
||||
public class BodyTagSupport extends TagSupport implements BodyTag {
|
||||
|
||||
private static final long serialVersionUID = -7235752615580319833L;
|
||||
|
||||
/**
|
||||
* Default constructor, all subclasses are required to only define a public
|
||||
* constructor with the same signature, and to call the superclass
|
||||
* constructor. This constructor is called by the code generated by the JSP
|
||||
* translator.
|
||||
*/
|
||||
public BodyTagSupport() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Default processing of the start tag returning EVAL_BODY_BUFFERED.
|
||||
*
|
||||
* @return EVAL_BODY_BUFFERED
|
||||
* @throws JspException
|
||||
* if an error occurred while processing this tag
|
||||
* @see BodyTag#doStartTag
|
||||
*/
|
||||
@Override
|
||||
public int doStartTag() throws JspException {
|
||||
return EVAL_BODY_BUFFERED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default processing of the end tag returning EVAL_PAGE.
|
||||
*
|
||||
* @return EVAL_PAGE
|
||||
* @throws JspException
|
||||
* if an error occurred while processing this tag
|
||||
* @see Tag#doEndTag
|
||||
*/
|
||||
@Override
|
||||
public int doEndTag() throws JspException {
|
||||
return super.doEndTag();
|
||||
}
|
||||
|
||||
// Actions related to body evaluation
|
||||
|
||||
/**
|
||||
* Prepare for evaluation of the body: stash the bodyContent away.
|
||||
*
|
||||
* @param b
|
||||
* the BodyContent
|
||||
* @see #doAfterBody
|
||||
* @see #doInitBody()
|
||||
* @see BodyTag#setBodyContent
|
||||
*/
|
||||
@Override
|
||||
public void setBodyContent(BodyContent b) {
|
||||
this.bodyContent = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare for evaluation of the body just before the first body evaluation:
|
||||
* no action.
|
||||
*
|
||||
* @throws JspException
|
||||
* if an error occurred while processing this tag
|
||||
* @see #setBodyContent
|
||||
* @see #doAfterBody
|
||||
* @see BodyTag#doInitBody
|
||||
*/
|
||||
@Override
|
||||
public void doInitBody() throws JspException {
|
||||
// NOOP by default
|
||||
}
|
||||
|
||||
/**
|
||||
* After the body evaluation: do not reevaluate and continue with the page.
|
||||
* By default nothing is done with the bodyContent data (if any).
|
||||
*
|
||||
* @return SKIP_BODY
|
||||
* @throws JspException
|
||||
* if an error occurred while processing this tag
|
||||
* @see #doInitBody
|
||||
* @see BodyTag#doAfterBody
|
||||
*/
|
||||
@Override
|
||||
public int doAfterBody() throws JspException {
|
||||
return SKIP_BODY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Release state.
|
||||
*
|
||||
* @see Tag#release
|
||||
*/
|
||||
@Override
|
||||
public void release() {
|
||||
bodyContent = null;
|
||||
|
||||
super.release();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current bodyContent.
|
||||
*
|
||||
* @return the body content.
|
||||
*/
|
||||
public BodyContent getBodyContent() {
|
||||
return bodyContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get surrounding out JspWriter.
|
||||
*
|
||||
* @return the enclosing JspWriter, from the bodyContent.
|
||||
*/
|
||||
public JspWriter getPreviousOut() {
|
||||
return bodyContent.getEnclosingWriter();
|
||||
}
|
||||
|
||||
// protected fields
|
||||
|
||||
/**
|
||||
* The current BodyContent for this BodyTag.
|
||||
*/
|
||||
protected transient BodyContent bodyContent;
|
||||
}
|
||||
52
java/javax/servlet/jsp/tagext/DynamicAttributes.java
Normal file
52
java/javax/servlet/jsp/tagext/DynamicAttributes.java
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.tagext;
|
||||
|
||||
import javax.servlet.jsp.JspException;
|
||||
|
||||
/**
|
||||
* For a tag to declare that it accepts dynamic attributes, it must implement
|
||||
* this interface. The entry for the tag in the Tag Library Descriptor must
|
||||
* also be configured to indicate dynamic attributes are accepted.
|
||||
* <br>
|
||||
* For any attribute that is not declared in the Tag Library Descriptor for
|
||||
* this tag, instead of getting an error at translation time, the
|
||||
* <code>setDynamicAttribute()</code> method is called, with the name and
|
||||
* value of the attribute. It is the responsibility of the tag to
|
||||
* remember the names and values of the dynamic attributes.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface DynamicAttributes {
|
||||
|
||||
/**
|
||||
* Called when a tag declared to accept dynamic attributes is passed
|
||||
* an attribute that is not declared in the Tag Library Descriptor.
|
||||
*
|
||||
* @param uri the namespace of the attribute, or null if in the default
|
||||
* namespace.
|
||||
* @param localName the name of the attribute being set.
|
||||
* @param value the value of the attribute
|
||||
* @throws JspException if the tag handler wishes to
|
||||
* signal that it does not accept the given attribute. The
|
||||
* container must not call doStartTag() or doTag() for this tag.
|
||||
*/
|
||||
public void setDynamicAttribute(
|
||||
String uri, String localName, Object value )
|
||||
throws JspException;
|
||||
|
||||
}
|
||||
79
java/javax/servlet/jsp/tagext/FunctionInfo.java
Normal file
79
java/javax/servlet/jsp/tagext/FunctionInfo.java
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.tagext;
|
||||
|
||||
/**
|
||||
* Information for a function in a Tag Library.
|
||||
* This class is instantiated from the Tag Library Descriptor file (TLD)
|
||||
* and is available only at translation time.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public class FunctionInfo {
|
||||
|
||||
/**
|
||||
* Constructor for FunctionInfo.
|
||||
*
|
||||
* @param name The name of the function
|
||||
* @param klass The class of the function
|
||||
* @param signature The signature of the function
|
||||
*/
|
||||
|
||||
public FunctionInfo(String name, String klass, String signature) {
|
||||
this.name = name;
|
||||
this.functionClass = klass;
|
||||
this.functionSignature = signature;
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the function.
|
||||
*
|
||||
* @return The name of the function
|
||||
*/
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The class of the function.
|
||||
*
|
||||
* @return The class of the function
|
||||
*/
|
||||
|
||||
public String getFunctionClass() {
|
||||
return functionClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* The signature of the function.
|
||||
*
|
||||
* @return The signature of the function
|
||||
*/
|
||||
|
||||
public String getFunctionSignature() {
|
||||
return functionSignature;
|
||||
}
|
||||
|
||||
/*
|
||||
* fields
|
||||
*/
|
||||
private final String name;
|
||||
private final String functionClass;
|
||||
private final String functionSignature;
|
||||
}
|
||||
121
java/javax/servlet/jsp/tagext/IterationTag.java
Normal file
121
java/javax/servlet/jsp/tagext/IterationTag.java
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.tagext;
|
||||
|
||||
import javax.servlet.jsp.JspException;
|
||||
|
||||
|
||||
/**
|
||||
* The IterationTag interface extends Tag by defining one additional
|
||||
* method that controls the reevaluation of its body.
|
||||
*
|
||||
* <p> A tag handler that implements IterationTag is treated as one that
|
||||
* implements Tag regarding the doStartTag() and doEndTag() methods.
|
||||
* IterationTag provides a new method: <code>doAfterBody()</code>.
|
||||
*
|
||||
* <p> The doAfterBody() method is invoked after every body evaluation
|
||||
* to control whether the body will be reevaluated or not. If doAfterBody()
|
||||
* returns IterationTag.EVAL_BODY_AGAIN, then the body will be reevaluated.
|
||||
* If doAfterBody() returns Tag.SKIP_BODY, then the body will be skipped
|
||||
* and doEndTag() will be evaluated instead.
|
||||
*
|
||||
* <p><B>Properties</B>
|
||||
* There are no new properties in addition to those in Tag.
|
||||
*
|
||||
* <p><B>Methods</B>
|
||||
* There is one new methods: doAfterBody().
|
||||
*
|
||||
* <p><B>Lifecycle</B>
|
||||
*
|
||||
* <p> Lifecycle details are described by the transition diagram
|
||||
* below. Exceptions that are thrown during the computation of
|
||||
* doStartTag(), BODY and doAfterBody() interrupt the execution
|
||||
* sequence and are propagated up the stack, unless the tag handler
|
||||
* implements the TryCatchFinally interface; see that interface for
|
||||
* details.
|
||||
*
|
||||
* <p>
|
||||
* <IMG src="doc-files/IterationTagProtocol.gif"
|
||||
* alt="Lifecycle Details Transition Diagram for IterationTag">
|
||||
*
|
||||
* <p><B>Empty and Non-Empty Action</B>
|
||||
* <p> If the TagLibraryDescriptor file indicates that the action must
|
||||
* always have an empty element body, by a <body-content> entry of
|
||||
* "empty", then the doStartTag() method must return SKIP_BODY.
|
||||
*
|
||||
* <p>Note that which methods are invoked after the doStartTag() depends on
|
||||
* both the return value and on if the custom action element is empty
|
||||
* or not in the JSP page, not on how it's declared in the TLD.
|
||||
*
|
||||
* <p>
|
||||
* If SKIP_BODY is returned the body is not evaluated, and then doEndTag()
|
||||
* is invoked.
|
||||
*
|
||||
* <p>
|
||||
* If EVAL_BODY_INCLUDE is returned, and the custom action element is not
|
||||
* empty, the body is evaluated and "passed through" to the current out,
|
||||
* then doAfterBody() is invoked and, after zero or more iterations,
|
||||
* doEndTag() is invoked.
|
||||
*/
|
||||
|
||||
public interface IterationTag extends Tag {
|
||||
|
||||
/**
|
||||
* Request the reevaluation of some body.
|
||||
* Returned from doAfterBody.
|
||||
*
|
||||
* For compatibility with JSP 1.1, the value is carefully selected
|
||||
* to be the same as the, now deprecated, BodyTag.EVAL_BODY_TAG,
|
||||
*
|
||||
*/
|
||||
|
||||
public static final int EVAL_BODY_AGAIN = 2;
|
||||
|
||||
/**
|
||||
* Process body (re)evaluation. This method is invoked by the
|
||||
* JSP Page implementation object after every evaluation of
|
||||
* the body into the BodyEvaluation object. The method is
|
||||
* not invoked if there is no body evaluation.
|
||||
*
|
||||
* <p>
|
||||
* If doAfterBody returns EVAL_BODY_AGAIN, a new evaluation of the
|
||||
* body will happen (followed by another invocation of doAfterBody).
|
||||
* If doAfterBody returns SKIP_BODY, no more body evaluations will occur,
|
||||
* and the doEndTag method will be invoked.
|
||||
*
|
||||
* <p>
|
||||
* If this tag handler implements BodyTag and doAfterBody returns
|
||||
* SKIP_BODY, the value of out will be restored using the popBody
|
||||
* method in pageContext prior to invoking doEndTag.
|
||||
*
|
||||
* <p>
|
||||
* The method re-invocations may be lead to different actions because
|
||||
* there might have been some changes to shared state, or because
|
||||
* of external computation.
|
||||
*
|
||||
* <p>
|
||||
* The JSP container will resynchronize the values of any AT_BEGIN and
|
||||
* NESTED variables (defined by the associated TagExtraInfo or TLD) after
|
||||
* the invocation of doAfterBody().
|
||||
*
|
||||
* @return whether additional evaluations of the body are desired
|
||||
* @throws JspException if an error occurred while processing this tag
|
||||
*/
|
||||
|
||||
int doAfterBody() throws JspException;
|
||||
}
|
||||
85
java/javax/servlet/jsp/tagext/JspFragment.java
Normal file
85
java/javax/servlet/jsp/tagext/JspFragment.java
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.tagext;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import javax.servlet.jsp.JspContext;
|
||||
import javax.servlet.jsp.JspException;
|
||||
|
||||
/**
|
||||
* Encapsulates a portion of JSP code in an object that
|
||||
* can be invoked as many times as needed. JSP Fragments are defined
|
||||
* using JSP syntax as the body of a tag for an invocation to a SimpleTag
|
||||
* handler, or as the body of a <jsp:attribute> standard action
|
||||
* specifying the value of an attribute that is declared as a fragment,
|
||||
* or to be of type JspFragment in the TLD.
|
||||
* <p>
|
||||
* The definition of the JSP fragment must only contain template
|
||||
* text and JSP action elements. In other words, it must not contain
|
||||
* scriptlets or scriptlet expressions. At translation time, the
|
||||
* container generates an implementation of the JspFragment abstract class
|
||||
* capable of executing the defined fragment.
|
||||
* <p>
|
||||
* A tag handler can invoke the fragment zero or more times, or
|
||||
* pass it along to other tags, before returning. To communicate values
|
||||
* to/from a JSP fragment, tag handlers store/retrieve values in
|
||||
* the JspContext associated with the fragment.
|
||||
* <p>
|
||||
* Note that tag library developers and page authors should not generate
|
||||
* JspFragment implementations manually.
|
||||
* <p>
|
||||
* <i>Implementation Note</i>: It is not necessary to generate a
|
||||
* separate class for each fragment. One possible implementation is
|
||||
* to generate a single helper class for each page that implements
|
||||
* JspFragment. Upon construction, a discriminator can be passed to
|
||||
* select which fragment that instance will execute.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public abstract class JspFragment {
|
||||
|
||||
/**
|
||||
* Executes the fragment and directs all output to the given Writer,
|
||||
* or the JspWriter returned by the getOut() method of the JspContext
|
||||
* associated with the fragment if out is null.
|
||||
*
|
||||
* @param out The Writer to output the fragment to, or null if
|
||||
* output should be sent to JspContext.getOut().
|
||||
* @throws javax.servlet.jsp.JspException Thrown if an error occurred
|
||||
* while invoking this fragment.
|
||||
* @throws javax.servlet.jsp.SkipPageException Thrown if the page
|
||||
* that (either directly or indirectly) invoked the tag handler that
|
||||
* invoked this fragment is to cease evaluation. The container
|
||||
* must throw this exception if a Classic Tag Handler returned
|
||||
* Tag.SKIP_PAGE or if a Simple Tag Handler threw SkipPageException.
|
||||
* @throws java.io.IOException If there was an error writing to the
|
||||
* stream.
|
||||
*/
|
||||
public abstract void invoke( Writer out )
|
||||
throws JspException, IOException;
|
||||
|
||||
/**
|
||||
* Returns the JspContext that is bound to this JspFragment.
|
||||
*
|
||||
* @return The JspContext used by this fragment at invocation time.
|
||||
*/
|
||||
public abstract JspContext getJspContext();
|
||||
|
||||
}
|
||||
21
java/javax/servlet/jsp/tagext/JspIdConsumer.java
Normal file
21
java/javax/servlet/jsp/tagext/JspIdConsumer.java
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.tagext;
|
||||
|
||||
public interface JspIdConsumer {
|
||||
public void setJspId(String jspId);
|
||||
}
|
||||
27
java/javax/servlet/jsp/tagext/JspTag.java
Normal file
27
java/javax/servlet/jsp/tagext/JspTag.java
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.tagext;
|
||||
|
||||
/**
|
||||
* Serves as a base class for Tag and SimpleTag.
|
||||
* This is mostly for organizational and type-safety purposes.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface JspTag {
|
||||
// No methods even through there are some common methods
|
||||
}
|
||||
50
java/javax/servlet/jsp/tagext/PageData.java
Normal file
50
java/javax/servlet/jsp/tagext/PageData.java
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.tagext;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Translation-time information on a JSP page. The information
|
||||
* corresponds to the XML view of the JSP page.
|
||||
*
|
||||
* <p>
|
||||
* Objects of this type are generated by the JSP translator, e.g.
|
||||
* when being passed to a TagLibraryValidator instance.
|
||||
*/
|
||||
|
||||
public abstract class PageData {
|
||||
|
||||
/**
|
||||
* Sole constructor. (For invocation by subclass constructors,
|
||||
* typically implicit.)
|
||||
*/
|
||||
public PageData() {
|
||||
// NOOP by default
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an input stream on the XML view of a JSP page.
|
||||
* The stream is encoded in UTF-8. Recall that the XML view of a
|
||||
* JSP page has the include directives expanded.
|
||||
*
|
||||
* @return An input stream on the document.
|
||||
*/
|
||||
public abstract InputStream getInputStream();
|
||||
}
|
||||
140
java/javax/servlet/jsp/tagext/SimpleTag.java
Normal file
140
java/javax/servlet/jsp/tagext/SimpleTag.java
Normal file
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.tagext;
|
||||
|
||||
import javax.servlet.jsp.JspContext;
|
||||
|
||||
/**
|
||||
* Interface for defining Simple Tag Handlers.
|
||||
*
|
||||
* <p>Simple Tag Handlers differ from Classic Tag Handlers in that instead
|
||||
* of supporting <code>doStartTag()</code> and <code>doEndTag()</code>,
|
||||
* the <code>SimpleTag</code> interface provides a simple
|
||||
* <code>doTag()</code> method, which is called once and only once for any
|
||||
* given tag invocation. All tag logic, iteration, body evaluations, etc.
|
||||
* are to be performed in this single method. Thus, simple tag handlers
|
||||
* have the equivalent power of <code>BodyTag</code>, but with a much
|
||||
* simpler lifecycle and interface.</p>
|
||||
*
|
||||
* <p>To support body content, the <code>setJspBody()</code>
|
||||
* method is provided. The container invokes the <code>setJspBody()</code>
|
||||
* method with a <code>JspFragment</code> object encapsulating the body of
|
||||
* the tag. The tag handler implementation can call
|
||||
* <code>invoke()</code> on that fragment to evaluate the body as
|
||||
* many times as it needs.</p>
|
||||
*
|
||||
* <p>A SimpleTag handler must have a public no-args constructor. Most
|
||||
* SimpleTag handlers should extend SimpleTagSupport.</p>
|
||||
*
|
||||
* <p><b>Lifecycle</b></p>
|
||||
*
|
||||
* <p>The following is a non-normative, brief overview of the
|
||||
* SimpleTag lifecycle. Refer to the JSP Specification for details.</p>
|
||||
*
|
||||
* <ol>
|
||||
* <li>A new tag handler instance is created each time by the container
|
||||
* by calling the provided zero-args constructor. Unlike classic
|
||||
* tag handlers, simple tag handlers are never cached and reused by
|
||||
* the JSP container.</li>
|
||||
* <li>The <code>setJspContext()</code> and <code>setParent()</code>
|
||||
* methods are called by the container. The <code>setParent()</code>
|
||||
* method is only called if the element is nested within another tag
|
||||
* invocation.</li>
|
||||
* <li>The setters for each attribute defined for this tag are called
|
||||
* by the container.</li>
|
||||
* <li>If a body exists, the <code>setJspBody()</code> method is called
|
||||
* by the container to set the body of this tag, as a
|
||||
* <code>JspFragment</code>. If the action element is empty in
|
||||
* the page, this method is not called at all.</li>
|
||||
* <li>The <code>doTag()</code> method is called by the container. All
|
||||
* tag logic, iteration, body evaluations, etc. occur in this
|
||||
* method.</li>
|
||||
* <li>The <code>doTag()</code> method returns and all variables are
|
||||
* synchronized.</li>
|
||||
* </ol>
|
||||
*
|
||||
* @see SimpleTagSupport
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface SimpleTag extends JspTag {
|
||||
|
||||
/**
|
||||
* Called by the container to invoke this tag.
|
||||
* The implementation of this method is provided by the tag library
|
||||
* developer, and handles all tag processing, body iteration, etc.
|
||||
*
|
||||
* <p>
|
||||
* The JSP container will resynchronize any AT_BEGIN and AT_END
|
||||
* variables (defined by the associated tag file, TagExtraInfo, or TLD)
|
||||
* after the invocation of doTag().
|
||||
*
|
||||
* @throws javax.servlet.jsp.JspException If an error occurred
|
||||
* while processing this tag.
|
||||
* @throws javax.servlet.jsp.SkipPageException If the page that
|
||||
* (either directly or indirectly) invoked this tag is to
|
||||
* cease evaluation. A Simple Tag Handler generated from a
|
||||
* tag file must throw this exception if an invoked Classic
|
||||
* Tag Handler returned SKIP_PAGE or if an invoked Simple
|
||||
* Tag Handler threw SkipPageException or if an invoked Jsp Fragment
|
||||
* threw a SkipPageException.
|
||||
* @throws java.io.IOException If there was an error writing to the
|
||||
* output stream.
|
||||
*/
|
||||
public void doTag()
|
||||
throws javax.servlet.jsp.JspException, java.io.IOException;
|
||||
|
||||
/**
|
||||
* Sets the parent of this tag, for collaboration purposes.
|
||||
* <p>
|
||||
* The container invokes this method only if this tag invocation is
|
||||
* nested within another tag invocation.
|
||||
*
|
||||
* @param parent the tag that encloses this tag
|
||||
*/
|
||||
public void setParent( JspTag parent );
|
||||
|
||||
/**
|
||||
* Returns the parent of this tag, for collaboration purposes.
|
||||
*
|
||||
* @return the parent of this tag
|
||||
*/
|
||||
public JspTag getParent();
|
||||
|
||||
/**
|
||||
* Called by the container to provide this tag handler with
|
||||
* the <code>JspContext</code> for this invocation.
|
||||
* An implementation should save this value.
|
||||
*
|
||||
* @param pc the page context for this invocation
|
||||
* @see Tag#setPageContext
|
||||
*/
|
||||
public void setJspContext( JspContext pc );
|
||||
|
||||
/**
|
||||
* Provides the body of this tag as a JspFragment object, able to be
|
||||
* invoked zero or more times by the tag handler.
|
||||
* <p>
|
||||
* This method is invoked by the JSP page implementation
|
||||
* object prior to <code>doTag()</code>. If the action element is
|
||||
* empty in the page, this method is not called at all.
|
||||
*
|
||||
* @param jspBody The fragment encapsulating the body of this tag.
|
||||
*/
|
||||
public void setJspBody( JspFragment jspBody );
|
||||
|
||||
|
||||
}
|
||||
216
java/javax/servlet/jsp/tagext/SimpleTagSupport.java
Normal file
216
java/javax/servlet/jsp/tagext/SimpleTagSupport.java
Normal file
@@ -0,0 +1,216 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.tagext;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.jsp.JspContext;
|
||||
import javax.servlet.jsp.JspException;
|
||||
|
||||
/**
|
||||
* A base class for defining tag handlers implementing SimpleTag.
|
||||
* <p>
|
||||
* The SimpleTagSupport class is a utility class intended to be used
|
||||
* as the base class for new simple tag handlers. The SimpleTagSupport
|
||||
* class implements the SimpleTag interface and adds additional
|
||||
* convenience methods including getter methods for the properties in
|
||||
* SimpleTag.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public class SimpleTagSupport implements SimpleTag {
|
||||
/** Reference to the enclosing tag. */
|
||||
private JspTag parentTag;
|
||||
|
||||
/** The JSP context for the upcoming tag invocation. */
|
||||
private JspContext jspContext;
|
||||
|
||||
/** The body of the tag. */
|
||||
private JspFragment jspBody;
|
||||
|
||||
/**
|
||||
* Sole constructor. (For invocation by subclass constructors,
|
||||
* typically implicit.)
|
||||
*/
|
||||
public SimpleTagSupport() {
|
||||
// NOOP by default
|
||||
}
|
||||
|
||||
/**
|
||||
* Default processing of the tag does nothing.
|
||||
*
|
||||
* @throws JspException Subclasses can throw JspException to indicate
|
||||
* an error occurred while processing this tag.
|
||||
* @throws javax.servlet.jsp.SkipPageException If the page that
|
||||
* (either directly or indirectly) invoked this tag is to
|
||||
* cease evaluation. A Simple Tag Handler generated from a
|
||||
* tag file must throw this exception if an invoked Classic
|
||||
* Tag Handler returned SKIP_PAGE or if an invoked Simple
|
||||
* Tag Handler threw SkipPageException or if an invoked Jsp Fragment
|
||||
* threw a SkipPageException.
|
||||
* @throws IOException Subclasses can throw IOException if there was
|
||||
* an error writing to the output stream
|
||||
* @see SimpleTag#doTag()
|
||||
*/
|
||||
@Override
|
||||
public void doTag() throws JspException, IOException {
|
||||
// NOOP by default
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the parent of this tag, for collaboration purposes.
|
||||
* <p>
|
||||
* The container invokes this method only if this tag invocation is
|
||||
* nested within another tag invocation.
|
||||
*
|
||||
* @param parent the tag that encloses this tag
|
||||
*/
|
||||
@Override
|
||||
public void setParent( JspTag parent ) {
|
||||
this.parentTag = parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parent of this tag, for collaboration purposes.
|
||||
*
|
||||
* @return the parent of this tag
|
||||
*/
|
||||
@Override
|
||||
public JspTag getParent() {
|
||||
return this.parentTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the provided JSP context in the private jspContext field.
|
||||
* Subclasses can access the <code>JspContext</code> via
|
||||
* <code>getJspContext()</code>.
|
||||
*
|
||||
* @param pc the page context for this invocation
|
||||
* @see SimpleTag#setJspContext
|
||||
*/
|
||||
@Override
|
||||
public void setJspContext( JspContext pc ) {
|
||||
this.jspContext = pc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the page context passed in by the container via
|
||||
* setJspContext.
|
||||
*
|
||||
* @return the page context for this invocation
|
||||
*/
|
||||
protected JspContext getJspContext() {
|
||||
return this.jspContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the provided JspFragment.
|
||||
*
|
||||
* @param jspBody The fragment encapsulating the body of this tag.
|
||||
* If the action element is empty in the page, this method is
|
||||
* not called at all.
|
||||
* @see SimpleTag#setJspBody
|
||||
*/
|
||||
@Override
|
||||
public void setJspBody( JspFragment jspBody ) {
|
||||
this.jspBody = jspBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the body passed in by the container via setJspBody.
|
||||
*
|
||||
* @return the fragment encapsulating the body of this tag, or
|
||||
* null if the action element is empty in the page.
|
||||
*/
|
||||
protected JspFragment getJspBody() {
|
||||
return this.jspBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the instance of a given class type that is closest to a given
|
||||
* instance.
|
||||
* This method uses the getParent method from the Tag and/or SimpleTag
|
||||
* interfaces. This method is used for coordination among
|
||||
* cooperating tags.
|
||||
*
|
||||
* <p> For every instance of TagAdapter
|
||||
* encountered while traversing the ancestors, the tag handler returned by
|
||||
* <code>TagAdapter.getAdaptee()</code> - instead of the TagAdapter itself -
|
||||
* is compared to <code>klass</code>. If the tag handler matches, it - and
|
||||
* not its TagAdapter - is returned.
|
||||
*
|
||||
* <p>
|
||||
* The current version of the specification only provides one formal
|
||||
* way of indicating the observable type of a tag handler: its
|
||||
* tag handler implementation class, described in the tag-class
|
||||
* subelement of the tag element. This is extended in an
|
||||
* informal manner by allowing the tag library author to
|
||||
* indicate in the description subelement an observable type.
|
||||
* The type should be a subtype of the tag handler implementation
|
||||
* class or void.
|
||||
* This additional constraint can be exploited by a
|
||||
* specialized container that knows about that specific tag library,
|
||||
* as in the case of the JSP standard tag library.
|
||||
*
|
||||
* <p>
|
||||
* When a tag library author provides information on the
|
||||
* observable type of a tag handler, client programmatic code
|
||||
* should adhere to that constraint. Specifically, the Class
|
||||
* passed to findAncestorWithClass should be a subtype of the
|
||||
* observable type.
|
||||
*
|
||||
*
|
||||
* @param from The instance from where to start looking.
|
||||
* @param klass The subclass of JspTag or interface to be matched
|
||||
* @return the nearest ancestor that implements the interface
|
||||
* or is an instance of the class specified
|
||||
*/
|
||||
public static final JspTag findAncestorWithClass(
|
||||
JspTag from, Class<?> klass)
|
||||
{
|
||||
boolean isInterface = false;
|
||||
|
||||
if (from == null || klass == null || (!JspTag.class.isAssignableFrom(klass) &&
|
||||
!(isInterface = klass.isInterface()))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
JspTag parent = null;
|
||||
if( from instanceof SimpleTag ) {
|
||||
parent = ((SimpleTag)from).getParent();
|
||||
}
|
||||
else if( from instanceof Tag ) {
|
||||
parent = ((Tag)from).getParent();
|
||||
}
|
||||
if (parent == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (parent instanceof TagAdapter) {
|
||||
parent = ((TagAdapter) parent).getAdaptee();
|
||||
}
|
||||
|
||||
if ((isInterface && klass.isInstance(parent)) ||
|
||||
klass.isAssignableFrom(parent.getClass())) {
|
||||
return parent;
|
||||
}
|
||||
|
||||
from = parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
264
java/javax/servlet/jsp/tagext/Tag.java
Normal file
264
java/javax/servlet/jsp/tagext/Tag.java
Normal file
@@ -0,0 +1,264 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.tagext;
|
||||
|
||||
import javax.servlet.jsp.JspException;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
|
||||
|
||||
/**
|
||||
* The interface of a classic tag handler that does not want to manipulate
|
||||
* its body. The Tag interface defines the basic protocol between a Tag
|
||||
* handler and JSP page implementation class. It defines the life cycle
|
||||
* and the methods to be invoked at start and end tag.
|
||||
*
|
||||
* <p><B>Properties</B></p>
|
||||
*
|
||||
* <p>The Tag interface specifies the setter and getter methods for the core
|
||||
* pageContext and parent properties.</p>
|
||||
*
|
||||
* <p>The JSP page implementation object invokes setPageContext and
|
||||
* setParent, in that order, before invoking doStartTag() or doEndTag().</p>
|
||||
*
|
||||
* <p><B>Methods</B></p>
|
||||
*
|
||||
* <p>There are two main actions: doStartTag and doEndTag. Once all
|
||||
* appropriate properties have been initialized, the doStartTag and
|
||||
* doEndTag methods can be invoked on the tag handler. Between these
|
||||
* invocations, the tag handler is assumed to hold a state that must
|
||||
* be preserved. After the doEndTag invocation, the tag handler is
|
||||
* available for further invocations (and it is expected to have
|
||||
* retained its properties).</p>
|
||||
*
|
||||
* <p><B>Lifecycle</B></p>
|
||||
*
|
||||
* <p>Lifecycle details are described by the transition diagram below,
|
||||
* with the following comments:</p>
|
||||
* <ul>
|
||||
* <li> [1] This transition is intended to be for releasing long-term data.
|
||||
* no guarantees are assumed on whether any properties have been retained
|
||||
* or not.
|
||||
* <li> [2] This transition happens if and only if the tag ends normally
|
||||
* without raising an exception
|
||||
* <li> [3] Some setters may be called again before a tag handler is
|
||||
* reused. For instance, <code>setParent()</code> is called if it's
|
||||
* reused within the same page but at a different level,
|
||||
* <code>setPageContext()</code> is called if it's used in another page,
|
||||
* and attribute setters are called if the values differ or are expressed
|
||||
* as request-time attribute values.
|
||||
* <li> Check the TryCatchFinally interface for additional details related
|
||||
* to exception handling and resource management.
|
||||
* </ul>
|
||||
*
|
||||
* <IMG src="doc-files/TagProtocol.gif"
|
||||
* alt="Lifecycle Details Transition Diagram for Tag">
|
||||
*
|
||||
* <p>Once all invocations on the tag handler
|
||||
* are completed, the release method is invoked on it. Once a release
|
||||
* method is invoked <em>all</em> properties, including parent and
|
||||
* pageContext, are assumed to have been reset to an unspecified value.
|
||||
* The page compiler guarantees that release() will be invoked on the Tag
|
||||
* handler before the handler is released to the GC.</p>
|
||||
*
|
||||
* <p><B>Empty and Non-Empty Action</B></p>
|
||||
* <p>If the TagLibraryDescriptor file indicates that the action must
|
||||
* always have an empty action, by an <body-content> entry of "empty",
|
||||
* then the doStartTag() method must return SKIP_BODY.</p>
|
||||
*
|
||||
* <p>Otherwise, the doStartTag() method may return SKIP_BODY or
|
||||
* EVAL_BODY_INCLUDE.</p>
|
||||
*
|
||||
* <p>If SKIP_BODY is returned the body, if present, is not evaluated.</p>
|
||||
*
|
||||
* <p>If EVAL_BODY_INCLUDE is returned, the body is evaluated and
|
||||
* "passed through" to the current out.</p>
|
||||
*/
|
||||
|
||||
public interface Tag extends JspTag {
|
||||
|
||||
/**
|
||||
* Skip body evaluation.
|
||||
* Valid return value for doStartTag and doAfterBody.
|
||||
*/
|
||||
|
||||
public static final int SKIP_BODY = 0;
|
||||
|
||||
/**
|
||||
* Evaluate body into existing out stream.
|
||||
* Valid return value for doStartTag.
|
||||
*/
|
||||
|
||||
public static final int EVAL_BODY_INCLUDE = 1;
|
||||
|
||||
/**
|
||||
* Skip the rest of the page.
|
||||
* Valid return value for doEndTag.
|
||||
*/
|
||||
|
||||
public static final int SKIP_PAGE = 5;
|
||||
|
||||
/**
|
||||
* Continue evaluating the page.
|
||||
* Valid return value for doEndTag().
|
||||
*/
|
||||
|
||||
public static final int EVAL_PAGE = 6;
|
||||
|
||||
// Setters for Tag handler data
|
||||
|
||||
|
||||
/**
|
||||
* Set the current page context.
|
||||
* This method is invoked by the JSP page implementation object
|
||||
* prior to doStartTag().
|
||||
* <p>
|
||||
* This value is *not* reset by doEndTag() and must be explicitly reset
|
||||
* by a page implementation if it changes between calls to doStartTag().
|
||||
*
|
||||
* @param pc The page context for this tag handler.
|
||||
*/
|
||||
|
||||
void setPageContext(PageContext pc);
|
||||
|
||||
|
||||
/**
|
||||
* Set the parent (closest enclosing tag handler) of this tag handler.
|
||||
* Invoked by the JSP page implementation object prior to doStartTag().
|
||||
* <p>
|
||||
* This value is *not* reset by doEndTag() and must be explicitly reset
|
||||
* by a page implementation.
|
||||
*
|
||||
* @param t The parent tag, or null.
|
||||
*/
|
||||
|
||||
|
||||
void setParent(Tag t);
|
||||
|
||||
|
||||
/**
|
||||
* Get the parent (closest enclosing tag handler) for this tag handler.
|
||||
*
|
||||
* <p>
|
||||
* The getParent() method can be used to navigate the nested tag
|
||||
* handler structure at runtime for cooperation among custom actions;
|
||||
* for example, the findAncestorWithClass() method in TagSupport
|
||||
* provides a convenient way of doing this.
|
||||
*
|
||||
* <p>
|
||||
* The current version of the specification only provides one formal
|
||||
* way of indicating the observable type of a tag handler: its
|
||||
* tag handler implementation class, described in the tag-class
|
||||
* sub-element of the tag element. This is extended in an
|
||||
* informal manner by allowing the tag library author to
|
||||
* indicate in the description sub-element an observable type.
|
||||
* The type should be a sub-type of the tag handler implementation
|
||||
* class or void.
|
||||
* This additional constraint can be exploited by a
|
||||
* specialized container that knows about that specific tag library,
|
||||
* as in the case of the JSP standard tag library.
|
||||
*
|
||||
* @return the current parent, or null if none.
|
||||
* @see TagSupport#findAncestorWithClass
|
||||
*/
|
||||
|
||||
Tag getParent();
|
||||
|
||||
|
||||
// Actions for basic start/end processing.
|
||||
|
||||
|
||||
/**
|
||||
* Process the start tag for this instance.
|
||||
* This method is invoked by the JSP page implementation object.
|
||||
*
|
||||
* <p>
|
||||
* The doStartTag method assumes that the properties pageContext and
|
||||
* parent have been set. It also assumes that any properties exposed as
|
||||
* attributes have been set too. When this method is invoked, the body
|
||||
* has not yet been evaluated.
|
||||
*
|
||||
* <p>
|
||||
* This method returns Tag.EVAL_BODY_INCLUDE or
|
||||
* BodyTag.EVAL_BODY_BUFFERED to indicate
|
||||
* that the body of the action should be evaluated or SKIP_BODY to
|
||||
* indicate otherwise.
|
||||
*
|
||||
* <p>
|
||||
* When a Tag returns EVAL_BODY_INCLUDE the result of evaluating
|
||||
* the body (if any) is included into the current "out" JspWriter as it
|
||||
* happens and then doEndTag() is invoked.
|
||||
*
|
||||
* <p>
|
||||
* BodyTag.EVAL_BODY_BUFFERED is only valid if the tag handler
|
||||
* implements BodyTag.
|
||||
*
|
||||
* <p>
|
||||
* The JSP container will resynchronize the values of any AT_BEGIN and
|
||||
* NESTED variables (defined by the associated TagExtraInfo or TLD)
|
||||
* after the invocation of doStartTag(), except for a tag handler
|
||||
* implementing BodyTag whose doStartTag() method returns
|
||||
* BodyTag.EVAL_BODY_BUFFERED.
|
||||
*
|
||||
* @return EVAL_BODY_INCLUDE if the tag wants to process body, SKIP_BODY
|
||||
* if it does not want to process it.
|
||||
* @throws JspException if an error occurred while processing this tag
|
||||
* @see BodyTag
|
||||
*/
|
||||
|
||||
int doStartTag() throws JspException;
|
||||
|
||||
|
||||
/**
|
||||
* Process the end tag for this instance.
|
||||
* This method is invoked by the JSP page implementation object
|
||||
* on all Tag handlers.
|
||||
*
|
||||
* <p>
|
||||
* This method will be called after returning from doStartTag. The
|
||||
* body of the action may or may not have been evaluated, depending on
|
||||
* the return value of doStartTag.
|
||||
*
|
||||
* <p>
|
||||
* If this method returns EVAL_PAGE, the rest of the page continues
|
||||
* to be evaluated. If this method returns SKIP_PAGE, the rest of
|
||||
* the page is not evaluated, the request is completed, and
|
||||
* the doEndTag() methods of enclosing tags are not invoked. If this
|
||||
* request was forwarded or included from another page (or Servlet),
|
||||
* only the current page evaluation is stopped.
|
||||
*
|
||||
* <p>
|
||||
* The JSP container will resynchronize the values of any AT_BEGIN and
|
||||
* AT_END variables (defined by the associated TagExtraInfo or TLD)
|
||||
* after the invocation of doEndTag().
|
||||
*
|
||||
* @return indication of whether to continue evaluating the JSP page.
|
||||
* @throws JspException if an error occurred while processing this tag
|
||||
*/
|
||||
|
||||
int doEndTag() throws JspException;
|
||||
|
||||
/**
|
||||
* Called on a Tag handler to release state.
|
||||
* The page compiler guarantees that JSP page implementation
|
||||
* objects will invoke this method on all tag handlers,
|
||||
* but there may be multiple invocations on doStartTag and doEndTag in between.
|
||||
*/
|
||||
|
||||
void release();
|
||||
|
||||
}
|
||||
167
java/javax/servlet/jsp/tagext/TagAdapter.java
Normal file
167
java/javax/servlet/jsp/tagext/TagAdapter.java
Normal file
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.tagext;
|
||||
|
||||
import javax.servlet.jsp.JspException;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
|
||||
/**
|
||||
* Wraps any SimpleTag and exposes it using a Tag interface. This is used to
|
||||
* allow collaboration between classic Tag handlers and SimpleTag handlers.
|
||||
* <p>
|
||||
* Because SimpleTag does not extend Tag, and because Tag.setParent() only
|
||||
* accepts a Tag instance, a classic tag handler (one that implements Tag)
|
||||
* cannot have a SimpleTag as its parent. To remedy this, a TagAdapter is
|
||||
* created to wrap the SimpleTag parent, and the adapter is passed to
|
||||
* setParent() instead. A classic Tag Handler can call getAdaptee() to retrieve
|
||||
* the encapsulated SimpleTag instance.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public class TagAdapter implements Tag {
|
||||
/** The simple tag that's being adapted. */
|
||||
private final SimpleTag simpleTagAdaptee;
|
||||
|
||||
/** The parent, of this tag, converted (if necessary) to be of type Tag. */
|
||||
private Tag parent;
|
||||
|
||||
// Flag indicating whether we have already determined the parent
|
||||
private boolean parentDetermined;
|
||||
|
||||
/**
|
||||
* Creates a new TagAdapter that wraps the given SimpleTag and returns the
|
||||
* parent tag when getParent() is called.
|
||||
*
|
||||
* @param adaptee
|
||||
* The SimpleTag being adapted as a Tag.
|
||||
*/
|
||||
public TagAdapter(SimpleTag adaptee) {
|
||||
if (adaptee == null) {
|
||||
// Cannot wrap a null adaptee.
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
this.simpleTagAdaptee = adaptee;
|
||||
}
|
||||
|
||||
/**
|
||||
* Must not be called.
|
||||
*
|
||||
* @param pc
|
||||
* ignored.
|
||||
* @throws UnsupportedOperationException
|
||||
* Must not be called
|
||||
*/
|
||||
@Override
|
||||
public void setPageContext(PageContext pc) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Illegal to invoke setPageContext() on TagAdapter wrapper");
|
||||
}
|
||||
|
||||
/**
|
||||
* Must not be called. The parent of this tag is always
|
||||
* getAdaptee().getParent().
|
||||
*
|
||||
* @param parentTag
|
||||
* ignored.
|
||||
* @throws UnsupportedOperationException
|
||||
* Must not be called.
|
||||
*/
|
||||
@Override
|
||||
public void setParent(Tag parentTag) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Illegal to invoke setParent() on TagAdapter wrapper");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parent of this tag, which is always getAdaptee().getParent().
|
||||
* This will either be the enclosing Tag (if getAdaptee().getParent()
|
||||
* implements Tag), or an adapter to the enclosing Tag (if
|
||||
* getAdaptee().getParent() does not implement Tag).
|
||||
*
|
||||
* @return The parent of the tag being adapted.
|
||||
*/
|
||||
@Override
|
||||
public Tag getParent() {
|
||||
if (!parentDetermined) {
|
||||
JspTag adapteeParent = simpleTagAdaptee.getParent();
|
||||
if (adapteeParent != null) {
|
||||
if (adapteeParent instanceof Tag) {
|
||||
this.parent = (Tag) adapteeParent;
|
||||
} else {
|
||||
// Must be SimpleTag - no other types defined.
|
||||
this.parent = new TagAdapter((SimpleTag) adapteeParent);
|
||||
}
|
||||
}
|
||||
parentDetermined = true;
|
||||
}
|
||||
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tag that is being adapted to the Tag interface. This should be
|
||||
* an instance of SimpleTag in JSP 2.0, but room is left for other kinds of
|
||||
* tags in future spec versions.
|
||||
*
|
||||
* @return the tag that is being adapted
|
||||
*/
|
||||
public JspTag getAdaptee() {
|
||||
return this.simpleTagAdaptee;
|
||||
}
|
||||
|
||||
/**
|
||||
* Must not be called.
|
||||
*
|
||||
* @return always throws UnsupportedOperationException
|
||||
* @throws UnsupportedOperationException
|
||||
* Must not be called
|
||||
* @throws JspException
|
||||
* never thrown
|
||||
*/
|
||||
@Override
|
||||
public int doStartTag() throws JspException {
|
||||
throw new UnsupportedOperationException(
|
||||
"Illegal to invoke doStartTag() on TagAdapter wrapper");
|
||||
}
|
||||
|
||||
/**
|
||||
* Must not be called.
|
||||
*
|
||||
* @return always throws UnsupportedOperationException
|
||||
* @throws UnsupportedOperationException
|
||||
* Must not be called
|
||||
* @throws JspException
|
||||
* never thrown
|
||||
*/
|
||||
@Override
|
||||
public int doEndTag() throws JspException {
|
||||
throw new UnsupportedOperationException(
|
||||
"Illegal to invoke doEndTag() on TagAdapter wrapper");
|
||||
}
|
||||
|
||||
/**
|
||||
* Must not be called.
|
||||
*
|
||||
* @throws UnsupportedOperationException
|
||||
* Must not be called
|
||||
*/
|
||||
@Override
|
||||
public void release() {
|
||||
throw new UnsupportedOperationException(
|
||||
"Illegal to invoke release() on TagAdapter wrapper");
|
||||
}
|
||||
}
|
||||
263
java/javax/servlet/jsp/tagext/TagAttributeInfo.java
Normal file
263
java/javax/servlet/jsp/tagext/TagAttributeInfo.java
Normal file
@@ -0,0 +1,263 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.tagext;
|
||||
|
||||
/**
|
||||
* Information on the attributes of a Tag, available at translation time. This
|
||||
* class is instantiated from the Tag Library Descriptor file (TLD).
|
||||
*
|
||||
* <p>
|
||||
* Only the information needed to generate code is included here. Other
|
||||
* information like SCHEMA for validation belongs elsewhere.
|
||||
*/
|
||||
|
||||
public class TagAttributeInfo {
|
||||
/**
|
||||
* "id" is wired in to be ID. There is no real benefit in having it be
|
||||
* something else IDREFs are not handled any differently.
|
||||
*/
|
||||
|
||||
public static final String ID = "id";
|
||||
|
||||
/**
|
||||
* Constructor for TagAttributeInfo. This class is to be instantiated only
|
||||
* from the TagLibrary code under request from some JSP code that is parsing
|
||||
* a TLD (Tag Library Descriptor).
|
||||
*
|
||||
* @param name
|
||||
* The name of the attribute.
|
||||
* @param required
|
||||
* If this attribute is required in tag instances.
|
||||
* @param type
|
||||
* The name of the type of the attribute.
|
||||
* @param reqTime
|
||||
* Whether this attribute holds a request-time Attribute.
|
||||
*/
|
||||
public TagAttributeInfo(String name, boolean required, String type,
|
||||
boolean reqTime) {
|
||||
this(name, required, type, reqTime, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* JSP 2.0 Constructor for TagAttributeInfo. This class is to be
|
||||
* instantiated only from the TagLibrary code under request from some JSP
|
||||
* code that is parsing a TLD (Tag Library Descriptor).
|
||||
*
|
||||
* @param name
|
||||
* The name of the attribute.
|
||||
* @param required
|
||||
* If this attribute is required in tag instances.
|
||||
* @param type
|
||||
* The name of the type of the attribute.
|
||||
* @param reqTime
|
||||
* Whether this attribute holds a request-time Attribute.
|
||||
* @param fragment
|
||||
* Whether this attribute is of type JspFragment
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public TagAttributeInfo(String name, boolean required, String type,
|
||||
boolean reqTime, boolean fragment) {
|
||||
this(name, required, type, reqTime, fragment, null, false, false, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* JSP 2.1 Constructor for TagAttributeInfo. This class is to be
|
||||
* instantiated only from the TagLibrary code under request from some JSP
|
||||
* code that is parsing a TLD (Tag Library Descriptor).
|
||||
*
|
||||
* @param name
|
||||
* The name of the attribute.
|
||||
* @param required
|
||||
* If this attribute is required in tag instances.
|
||||
* @param type
|
||||
* The name of the type of the attribute.
|
||||
* @param reqTime
|
||||
* Whether this attribute holds a request-time Attribute.
|
||||
* @param fragment
|
||||
* Whether this attribute is of type JspFragment
|
||||
* @param description
|
||||
* Description of this attribute
|
||||
* @param deferredValue
|
||||
* Does this attribute accept value expressions (written as
|
||||
* Strings) as attribute values the evaluation of which is
|
||||
* deferred until calculated by the tag
|
||||
* @param deferredMethod
|
||||
* Does this attribute accept method expressions (written as
|
||||
* Strings) as attribute values the evaluation of which is
|
||||
* deferred until calculated by the tag
|
||||
* @param expectedTypeName
|
||||
* The expected type when the deferred value is evaluated
|
||||
* @param methodSignature
|
||||
* The expected method signature if a deferred method
|
||||
*
|
||||
* @since JSP 2.1
|
||||
*/
|
||||
public TagAttributeInfo(String name, boolean required, String type,
|
||||
boolean reqTime, boolean fragment, String description,
|
||||
boolean deferredValue, boolean deferredMethod,
|
||||
String expectedTypeName, String methodSignature) {
|
||||
this.name = name;
|
||||
this.required = required;
|
||||
this.type = type;
|
||||
this.reqTime = reqTime;
|
||||
this.fragment = fragment;
|
||||
this.description = description;
|
||||
this.deferredValue = deferredValue;
|
||||
this.deferredMethod = deferredMethod;
|
||||
this.expectedTypeName = expectedTypeName;
|
||||
this.methodSignature = methodSignature;
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of this attribute.
|
||||
*
|
||||
* @return the name of the attribute
|
||||
*/
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type (as a String) of this attribute.
|
||||
*
|
||||
* @return the type of the attribute
|
||||
*/
|
||||
|
||||
public String getTypeName() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this attribute can hold a request-time value.
|
||||
*
|
||||
* @return if the attribute can hold a request-time value.
|
||||
*/
|
||||
|
||||
public boolean canBeRequestTime() {
|
||||
return reqTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this attribute is required.
|
||||
*
|
||||
* @return if the attribute is required.
|
||||
*/
|
||||
public boolean isRequired() {
|
||||
return required;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience static method that goes through an array of TagAttributeInfo
|
||||
* objects and looks for "id".
|
||||
*
|
||||
* @param a
|
||||
* An array of TagAttributeInfo
|
||||
* @return The TagAttributeInfo reference with name "id"
|
||||
*/
|
||||
public static TagAttributeInfo getIdAttribute(TagAttributeInfo a[]) {
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
if (a[i].getName().equals(ID)) {
|
||||
return a[i];
|
||||
}
|
||||
}
|
||||
return null; // no such attribute
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this attribute is of type JspFragment.
|
||||
*
|
||||
* @return if the attribute is of type JspFragment
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public boolean isFragment() {
|
||||
return fragment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a String representation of this TagAttributeInfo, suitable for
|
||||
* debugging purposes.
|
||||
*
|
||||
* @return a String representation of this TagAttributeInfo
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder b = new StringBuilder(64);
|
||||
b.append("name = " + name + " ");
|
||||
b.append("type = " + type + " ");
|
||||
b.append("reqTime = " + reqTime + " ");
|
||||
b.append("required = " + required + " ");
|
||||
b.append("fragment = " + fragment + " ");
|
||||
b.append("deferredValue = " + deferredValue + " ");
|
||||
b.append("expectedTypeName = " + expectedTypeName + " ");
|
||||
b.append("deferredMethod = " + deferredMethod + " ");
|
||||
b.append("methodSignature = " + methodSignature);
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
/*
|
||||
* private fields
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
private final String type;
|
||||
|
||||
private final boolean reqTime;
|
||||
|
||||
private final boolean required;
|
||||
|
||||
/*
|
||||
* private fields for JSP 2.0
|
||||
*/
|
||||
private final boolean fragment;
|
||||
|
||||
/*
|
||||
* private fields for JSP 2.1
|
||||
*/
|
||||
private final String description;
|
||||
|
||||
private final boolean deferredValue;
|
||||
|
||||
private final boolean deferredMethod;
|
||||
|
||||
private final String expectedTypeName;
|
||||
|
||||
private final String methodSignature;
|
||||
|
||||
public boolean isDeferredMethod() {
|
||||
return deferredMethod;
|
||||
}
|
||||
|
||||
public boolean isDeferredValue() {
|
||||
return deferredValue;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getExpectedTypeName() {
|
||||
return expectedTypeName;
|
||||
}
|
||||
|
||||
public String getMethodSignature() {
|
||||
return methodSignature;
|
||||
}
|
||||
}
|
||||
153
java/javax/servlet/jsp/tagext/TagData.java
Normal file
153
java/javax/servlet/jsp/tagext/TagData.java
Normal file
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.tagext;
|
||||
|
||||
import java.util.Hashtable;
|
||||
|
||||
/**
|
||||
* The (translation-time only) attribute/value information for a tag instance.
|
||||
*
|
||||
* <p>
|
||||
* TagData is only used as an argument to the isValid, validate, and
|
||||
* getVariableInfo methods of TagExtraInfo, which are invoked at
|
||||
* translation time.
|
||||
*/
|
||||
|
||||
public class TagData implements Cloneable {
|
||||
|
||||
/**
|
||||
* Distinguished value for an attribute to indicate its value
|
||||
* is a request-time expression (which is not yet available because
|
||||
* TagData instances are used at translation-time).
|
||||
*/
|
||||
|
||||
public static final Object REQUEST_TIME_VALUE = new Object();
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for TagData.
|
||||
*
|
||||
* <p>
|
||||
* A typical constructor may be
|
||||
* <pre>
|
||||
* static final Object[][] att = {{"connection", "conn0"}, {"id", "query0"}};
|
||||
* static final TagData td = new TagData(att);
|
||||
* </pre>
|
||||
*
|
||||
* All values must be Strings except for those holding the
|
||||
* distinguished object REQUEST_TIME_VALUE.
|
||||
|
||||
* @param atts the static attribute and values. May be null.
|
||||
*/
|
||||
public TagData(Object[] atts[]) {
|
||||
if (atts == null) {
|
||||
attributes = new Hashtable<>();
|
||||
} else {
|
||||
attributes = new Hashtable<>(atts.length);
|
||||
}
|
||||
|
||||
if (atts != null) {
|
||||
for (int i = 0; i < atts.length; i++) {
|
||||
attributes.put((String) atts[i][0], atts[i][1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for a TagData.
|
||||
*
|
||||
* If you already have the attributes in a hashtable, use this
|
||||
* constructor.
|
||||
*
|
||||
* @param attrs A hashtable to get the values from.
|
||||
*/
|
||||
public TagData(Hashtable<String, Object> attrs) {
|
||||
this.attributes = attrs;
|
||||
}
|
||||
|
||||
/**
|
||||
* The value of the tag's id attribute.
|
||||
*
|
||||
* @return the value of the tag's id attribute, or null if no such
|
||||
* attribute was specified.
|
||||
*/
|
||||
|
||||
public String getId() {
|
||||
return getAttributeString(TagAttributeInfo.ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* The value of the attribute.
|
||||
* If a static value is specified for an attribute that accepts a
|
||||
* request-time attribute expression then that static value is returned,
|
||||
* even if the value is provided in the body of a <jsp:attribute>
|
||||
* action. The distinguished object REQUEST_TIME_VALUE is only returned if
|
||||
* the value is specified as a request-time attribute expression
|
||||
* or via the <jsp:attribute> action with a body that contains
|
||||
* dynamic content (scriptlets, scripting expressions, EL expressions,
|
||||
* standard actions, or custom actions). Returns null if the attribute
|
||||
* is not set.
|
||||
*
|
||||
* @param attName the name of the attribute
|
||||
* @return the attribute's value
|
||||
*/
|
||||
|
||||
public Object getAttribute(String attName) {
|
||||
return attributes.get(attName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of an attribute.
|
||||
*
|
||||
* @param attName the name of the attribute
|
||||
* @param value the value.
|
||||
*/
|
||||
public void setAttribute(String attName,
|
||||
Object value) {
|
||||
attributes.put(attName, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value for a given attribute.
|
||||
*
|
||||
* @param attName the name of the attribute
|
||||
* @return the attribute value string
|
||||
* @throws ClassCastException if attribute value is not a String
|
||||
*/
|
||||
|
||||
public String getAttributeString(String attName) {
|
||||
Object o = attributes.get(attName);
|
||||
if (o == null) {
|
||||
return null;
|
||||
}
|
||||
return (String) o;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumerates the attributes.
|
||||
*
|
||||
*@return An enumeration of the attributes in a TagData
|
||||
*/
|
||||
public java.util.Enumeration<String> getAttributes() {
|
||||
return attributes.keys();
|
||||
}
|
||||
|
||||
// private data
|
||||
|
||||
private final Hashtable<String, Object> attributes; // the tagname/value map
|
||||
}
|
||||
145
java/javax/servlet/jsp/tagext/TagExtraInfo.java
Normal file
145
java/javax/servlet/jsp/tagext/TagExtraInfo.java
Normal file
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.tagext;
|
||||
|
||||
/**
|
||||
* Optional class provided by the tag library author to describe additional
|
||||
* translation-time information not described in the TLD.
|
||||
* The TagExtraInfo class is mentioned in the Tag Library Descriptor file (TLD).
|
||||
*
|
||||
* <p>
|
||||
* This class can be used:
|
||||
* <ul>
|
||||
* <li> to indicate that the tag defines scripting variables
|
||||
* <li> to perform translation-time validation of the tag attributes.
|
||||
* </ul>
|
||||
*
|
||||
* <p>
|
||||
* It is the responsibility of the JSP translator that the initial value
|
||||
* to be returned by calls to getTagInfo() corresponds to a TagInfo
|
||||
* object for the tag being translated. If an explicit call to
|
||||
* setTagInfo() is done, then the object passed will be returned in
|
||||
* subsequent calls to getTagInfo().
|
||||
*
|
||||
* <p>
|
||||
* The only way to affect the value returned by getTagInfo()
|
||||
* is through a setTagInfo() call, and thus, TagExtraInfo.setTagInfo() is
|
||||
* to be called by the JSP translator, with a TagInfo object that
|
||||
* corresponds to the tag being translated. The call should happen before
|
||||
* any invocation on validate() and before any invocation on
|
||||
* getVariableInfo().
|
||||
*
|
||||
* <p>
|
||||
* <b>NOTE:</b> It is a (translation time) error for a tag definition
|
||||
* in a TLD with one or more variable subelements to have an associated
|
||||
* TagExtraInfo implementation that returns a VariableInfo array with
|
||||
* one or more elements from a call to getVariableInfo().
|
||||
*/
|
||||
|
||||
public abstract class TagExtraInfo {
|
||||
|
||||
/**
|
||||
* Sole constructor. (For invocation by subclass constructors,
|
||||
* typically implicit.)
|
||||
*/
|
||||
public TagExtraInfo() {
|
||||
// NOOP by default
|
||||
}
|
||||
|
||||
/**
|
||||
* information on scripting variables defined by the tag associated with
|
||||
* this TagExtraInfo instance.
|
||||
* Request-time attributes are indicated as such in the TagData parameter.
|
||||
*
|
||||
* @param data The TagData instance.
|
||||
* @return An array of VariableInfo data, or null or a zero length array
|
||||
* if no scripting variables are to be defined.
|
||||
*/
|
||||
public VariableInfo[] getVariableInfo(TagData data) {
|
||||
return ZERO_VARIABLE_INFO;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translation-time validation of the attributes.
|
||||
* Request-time attributes are indicated as such in the TagData parameter.
|
||||
* Note that the preferred way to do validation is with the validate()
|
||||
* method, since it can return more detailed information.
|
||||
*
|
||||
* @param data The TagData instance.
|
||||
* @return Whether this tag instance is valid.
|
||||
* @see TagExtraInfo#validate
|
||||
*/
|
||||
|
||||
public boolean isValid(TagData data) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translation-time validation of the attributes.
|
||||
* Request-time attributes are indicated as such in the TagData parameter.
|
||||
* Because of the higher quality validation messages possible,
|
||||
* this is the preferred way to do validation (although isValid()
|
||||
* still works).
|
||||
*
|
||||
* <p>JSP 2.0 and higher containers call validate() instead of isValid().
|
||||
* The default implementation of this method is to call isValid(). If
|
||||
* isValid() returns false, a generic ValidationMessage[] is returned
|
||||
* indicating isValid() returned false.</p>
|
||||
*
|
||||
* @param data The TagData instance.
|
||||
* @return A null object, or zero length array if no errors, an
|
||||
* array of ValidationMessages otherwise.
|
||||
* @since 2.0
|
||||
*/
|
||||
public ValidationMessage[] validate( TagData data ) {
|
||||
ValidationMessage[] result = null;
|
||||
|
||||
if( !isValid( data ) ) {
|
||||
result = new ValidationMessage[] {
|
||||
new ValidationMessage( data.getId(), "isValid() == false" ) };
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the TagInfo for this class.
|
||||
*
|
||||
* @param tagInfo The TagInfo this instance is extending
|
||||
*/
|
||||
public final void setTagInfo(TagInfo tagInfo) {
|
||||
this.tagInfo = tagInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the TagInfo for this class.
|
||||
*
|
||||
* @return the taginfo instance this instance is extending
|
||||
*/
|
||||
public final TagInfo getTagInfo() {
|
||||
return tagInfo;
|
||||
}
|
||||
|
||||
// private data
|
||||
private TagInfo tagInfo;
|
||||
|
||||
// zero length VariableInfo array
|
||||
private static final VariableInfo[] ZERO_VARIABLE_INFO = { };
|
||||
}
|
||||
|
||||
86
java/javax/servlet/jsp/tagext/TagFileInfo.java
Normal file
86
java/javax/servlet/jsp/tagext/TagFileInfo.java
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.tagext;
|
||||
|
||||
/**
|
||||
* Tag information for a tag file in a Tag Library;
|
||||
* This class is instantiated from the Tag Library Descriptor file (TLD)
|
||||
* and is available only at translation time.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public class TagFileInfo {
|
||||
|
||||
/**
|
||||
* Constructor for TagFileInfo from data in the JSP 2.0 format for TLD.
|
||||
* This class is to be instantiated only from the TagLibrary code
|
||||
* under request from some JSP code that is parsing a
|
||||
* TLD (Tag Library Descriptor).
|
||||
*
|
||||
* Note that, since TagLibraryInfo reflects both TLD information
|
||||
* and taglib directive information, a TagFileInfo instance is
|
||||
* dependent on a taglib directive. This is probably a
|
||||
* design error, which may be fixed in the future.
|
||||
*
|
||||
* @param name The unique action name of this tag
|
||||
* @param path Where to find the .tag file implementing this
|
||||
* action, relative to the location of the TLD file.
|
||||
* @param tagInfo The detailed information about this tag, as parsed
|
||||
* from the directives in the tag file.
|
||||
*/
|
||||
public TagFileInfo( String name, String path, TagInfo tagInfo ) {
|
||||
this.name = name;
|
||||
this.path = path;
|
||||
this.tagInfo = tagInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* The unique action name of this tag.
|
||||
*
|
||||
* @return The (short) name of the tag.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Where to find the .tag file implementing this action.
|
||||
*
|
||||
* @return The path of the tag file, relative to the TLD, or "." if
|
||||
* the tag file was defined in an implicit tag file.
|
||||
*/
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information about this tag, parsed from the directives
|
||||
* in the tag file.
|
||||
*
|
||||
* @return a TagInfo object containing information about this tag
|
||||
*/
|
||||
public TagInfo getTagInfo() {
|
||||
return tagInfo;
|
||||
}
|
||||
|
||||
// private fields for 2.0 info
|
||||
private final String name;
|
||||
private final String path;
|
||||
private final TagInfo tagInfo;
|
||||
}
|
||||
457
java/javax/servlet/jsp/tagext/TagInfo.java
Normal file
457
java/javax/servlet/jsp/tagext/TagInfo.java
Normal file
@@ -0,0 +1,457 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.tagext;
|
||||
|
||||
/**
|
||||
* Tag information for a tag in a Tag Library;
|
||||
* This class is instantiated from the Tag Library Descriptor file (TLD)
|
||||
* and is available only at translation time.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
public class TagInfo {
|
||||
|
||||
/**
|
||||
* Static constant for getBodyContent() when it is JSP.
|
||||
*/
|
||||
|
||||
public static final String BODY_CONTENT_JSP = "JSP";
|
||||
|
||||
/**
|
||||
* Static constant for getBodyContent() when it is Tag dependent.
|
||||
*/
|
||||
|
||||
public static final String BODY_CONTENT_TAG_DEPENDENT = "tagdependent";
|
||||
|
||||
|
||||
/**
|
||||
* Static constant for getBodyContent() when it is empty.
|
||||
*/
|
||||
|
||||
public static final String BODY_CONTENT_EMPTY = "empty";
|
||||
|
||||
/**
|
||||
* Static constant for getBodyContent() when it is scriptless.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public static final String BODY_CONTENT_SCRIPTLESS = "scriptless";
|
||||
|
||||
/**
|
||||
* Constructor for TagInfo from data in the JSP 1.1 format for TLD.
|
||||
* This class is to be instantiated only from the TagLibrary code
|
||||
* under request from some JSP code that is parsing a
|
||||
* TLD (Tag Library Descriptor).
|
||||
*
|
||||
* Note that, since TagLibraryInfo reflects both TLD information
|
||||
* and taglib directive information, a TagInfo instance is
|
||||
* dependent on a taglib directive. This is probably a
|
||||
* design error, which may be fixed in the future.
|
||||
*
|
||||
* @param tagName The name of this tag
|
||||
* @param tagClassName The name of the tag handler class
|
||||
* @param bodycontent Information on the body content of these tags
|
||||
* @param infoString The (optional) string information for this tag
|
||||
* @param taglib The instance of the tag library that contains us.
|
||||
* @param tagExtraInfo The instance providing extra Tag info. May be null
|
||||
* @param attributeInfo An array of AttributeInfo data from descriptor.
|
||||
* May be null;
|
||||
*
|
||||
*/
|
||||
public TagInfo(String tagName,
|
||||
String tagClassName,
|
||||
String bodycontent,
|
||||
String infoString,
|
||||
TagLibraryInfo taglib,
|
||||
TagExtraInfo tagExtraInfo,
|
||||
TagAttributeInfo[] attributeInfo) {
|
||||
this.tagName = tagName;
|
||||
this.tagClassName = tagClassName;
|
||||
this.bodyContent = bodycontent;
|
||||
this.infoString = infoString;
|
||||
this.tagLibrary = taglib;
|
||||
this.tagExtraInfo = tagExtraInfo;
|
||||
this.attributeInfo = attributeInfo;
|
||||
|
||||
// Use defaults for unspecified values
|
||||
this.displayName = null;
|
||||
this.largeIcon = null;
|
||||
this.smallIcon = null;
|
||||
this.tagVariableInfo = null;
|
||||
this.dynamicAttributes = false;
|
||||
|
||||
if (tagExtraInfo != null)
|
||||
tagExtraInfo.setTagInfo(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for TagInfo from data in the JSP 1.2 format for TLD.
|
||||
* This class is to be instantiated only from the TagLibrary code
|
||||
* under request from some JSP code that is parsing a
|
||||
* TLD (Tag Library Descriptor).
|
||||
*
|
||||
* Note that, since TagLibraryInfo reflects both TLD information
|
||||
* and taglib directive information, a TagInfo instance is
|
||||
* dependent on a taglib directive. This is probably a
|
||||
* design error, which may be fixed in the future.
|
||||
*
|
||||
* @param tagName The name of this tag
|
||||
* @param tagClassName The name of the tag handler class
|
||||
* @param bodycontent Information on the body content of these tags
|
||||
* @param infoString The (optional) string information for this tag
|
||||
* @param taglib The instance of the tag library that contains us.
|
||||
* @param tagExtraInfo The instance providing extra Tag info. May be null
|
||||
* @param attributeInfo An array of AttributeInfo data from descriptor.
|
||||
* May be null;
|
||||
* @param displayName A short name to be displayed by tools
|
||||
* @param smallIcon Path to a small icon to be displayed by tools
|
||||
* @param largeIcon Path to a large icon to be displayed by tools
|
||||
* @param tvi An array of a TagVariableInfo (or null)
|
||||
*/
|
||||
public TagInfo(String tagName,
|
||||
String tagClassName,
|
||||
String bodycontent,
|
||||
String infoString,
|
||||
TagLibraryInfo taglib,
|
||||
TagExtraInfo tagExtraInfo,
|
||||
TagAttributeInfo[] attributeInfo,
|
||||
String displayName,
|
||||
String smallIcon,
|
||||
String largeIcon,
|
||||
TagVariableInfo[] tvi) {
|
||||
this.tagName = tagName;
|
||||
this.tagClassName = tagClassName;
|
||||
this.bodyContent = bodycontent;
|
||||
this.infoString = infoString;
|
||||
this.tagLibrary = taglib;
|
||||
this.tagExtraInfo = tagExtraInfo;
|
||||
this.attributeInfo = attributeInfo;
|
||||
this.displayName = displayName;
|
||||
this.smallIcon = smallIcon;
|
||||
this.largeIcon = largeIcon;
|
||||
this.tagVariableInfo = tvi;
|
||||
|
||||
// Use defaults for unspecified values
|
||||
this.dynamicAttributes = false;
|
||||
|
||||
if (tagExtraInfo != null)
|
||||
tagExtraInfo.setTagInfo(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for TagInfo from data in the JSP 2.0 format for TLD.
|
||||
* This class is to be instantiated only from the TagLibrary code
|
||||
* under request from some JSP code that is parsing a
|
||||
* TLD (Tag Library Descriptor).
|
||||
*
|
||||
* Note that, since TagLibraryInfo reflects both TLD information
|
||||
* and taglib directive information, a TagInfo instance is
|
||||
* dependent on a taglib directive. This is probably a
|
||||
* design error, which may be fixed in the future.
|
||||
*
|
||||
* @param tagName The name of this tag
|
||||
* @param tagClassName The name of the tag handler class
|
||||
* @param bodycontent Information on the body content of these tags
|
||||
* @param infoString The (optional) string information for this tag
|
||||
* @param taglib The instance of the tag library that contains us.
|
||||
* @param tagExtraInfo The instance providing extra Tag info. May be null
|
||||
* @param attributeInfo An array of AttributeInfo data from descriptor.
|
||||
* May be null;
|
||||
* @param displayName A short name to be displayed by tools
|
||||
* @param smallIcon Path to a small icon to be displayed by tools
|
||||
* @param largeIcon Path to a large icon to be displayed by tools
|
||||
* @param tvi An array of a TagVariableInfo (or null)
|
||||
* @param dynamicAttributes True if supports dynamic attributes
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public TagInfo(String tagName,
|
||||
String tagClassName,
|
||||
String bodycontent,
|
||||
String infoString,
|
||||
TagLibraryInfo taglib,
|
||||
TagExtraInfo tagExtraInfo,
|
||||
TagAttributeInfo[] attributeInfo,
|
||||
String displayName,
|
||||
String smallIcon,
|
||||
String largeIcon,
|
||||
TagVariableInfo[] tvi,
|
||||
boolean dynamicAttributes) {
|
||||
this.tagName = tagName;
|
||||
this.tagClassName = tagClassName;
|
||||
this.bodyContent = bodycontent;
|
||||
this.infoString = infoString;
|
||||
this.tagLibrary = taglib;
|
||||
this.tagExtraInfo = tagExtraInfo;
|
||||
this.attributeInfo = attributeInfo;
|
||||
this.displayName = displayName;
|
||||
this.smallIcon = smallIcon;
|
||||
this.largeIcon = largeIcon;
|
||||
this.tagVariableInfo = tvi;
|
||||
this.dynamicAttributes = dynamicAttributes;
|
||||
|
||||
if (tagExtraInfo != null)
|
||||
tagExtraInfo.setTagInfo(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the Tag.
|
||||
*
|
||||
* @return The (short) name of the tag.
|
||||
*/
|
||||
|
||||
public String getTagName() {
|
||||
return tagName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attribute information (in the TLD) on this tag.
|
||||
* The return is an array describing the attributes of this tag, as
|
||||
* indicated in the TLD.
|
||||
*
|
||||
* @return The array of TagAttributeInfo for this tag, or a
|
||||
* zero-length array if the tag has no attributes.
|
||||
*/
|
||||
|
||||
public TagAttributeInfo[] getAttributes() {
|
||||
return attributeInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Information on the scripting objects created by this tag at runtime.
|
||||
* This is a convenience method on the associated TagExtraInfo class.
|
||||
*
|
||||
* @param data TagData describing this action.
|
||||
* @return if a TagExtraInfo object is associated with this TagInfo, the
|
||||
* result of getTagExtraInfo().getVariableInfo( data ), otherwise
|
||||
* null.
|
||||
*/
|
||||
public VariableInfo[] getVariableInfo(TagData data) {
|
||||
VariableInfo[] result = null;
|
||||
TagExtraInfo tei = getTagExtraInfo();
|
||||
if (tei != null) {
|
||||
result = tei.getVariableInfo( data );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translation-time validation of the attributes.
|
||||
* This is a convenience method on the associated TagExtraInfo class.
|
||||
*
|
||||
* @param data The translation-time TagData instance.
|
||||
* @return Whether the data is valid.
|
||||
*/
|
||||
public boolean isValid(TagData data) {
|
||||
TagExtraInfo tei = getTagExtraInfo();
|
||||
if (tei == null) {
|
||||
return true;
|
||||
}
|
||||
return tei.isValid(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translation-time validation of the attributes.
|
||||
* This is a convenience method on the associated TagExtraInfo class.
|
||||
*
|
||||
* @param data The translation-time TagData instance.
|
||||
* @return A null object, or zero length array if no errors, an
|
||||
* array of ValidationMessages otherwise.
|
||||
* @since 2.0
|
||||
*/
|
||||
public ValidationMessage[] validate( TagData data ) {
|
||||
TagExtraInfo tei = getTagExtraInfo();
|
||||
if( tei == null ) {
|
||||
return null;
|
||||
}
|
||||
return tei.validate( data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the instance for extra tag information.
|
||||
*
|
||||
* @param tei the TagExtraInfo instance
|
||||
*/
|
||||
public void setTagExtraInfo(TagExtraInfo tei) {
|
||||
tagExtraInfo = tei;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The instance (if any) for extra tag information.
|
||||
*
|
||||
* @return The TagExtraInfo instance, if any.
|
||||
*/
|
||||
public TagExtraInfo getTagExtraInfo() {
|
||||
return tagExtraInfo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Name of the class that provides the handler for this tag.
|
||||
*
|
||||
* @return The name of the tag handler class.
|
||||
*/
|
||||
|
||||
public String getTagClassName() {
|
||||
return tagClassName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The bodycontent information for this tag.
|
||||
* If the bodycontent is not defined for this
|
||||
* tag, the default of JSP will be returned.
|
||||
*
|
||||
* @return the body content string.
|
||||
*/
|
||||
|
||||
public String getBodyContent() {
|
||||
return bodyContent;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The information string for the tag.
|
||||
*
|
||||
* @return the info string, or null if
|
||||
* not defined
|
||||
*/
|
||||
|
||||
public String getInfoString() {
|
||||
return infoString;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the TagLibraryInfo property.
|
||||
*
|
||||
* Note that a TagLibraryInfo element is dependent
|
||||
* not just on the TLD information but also on the
|
||||
* specific taglib instance used. This means that
|
||||
* a fair amount of work needs to be done to construct
|
||||
* and initialize TagLib objects.
|
||||
*
|
||||
* If used carefully, this setter can be used to avoid having to
|
||||
* create new TagInfo elements for each taglib directive.
|
||||
*
|
||||
* @param tl the TagLibraryInfo to assign
|
||||
*/
|
||||
|
||||
public void setTagLibrary(TagLibraryInfo tl) {
|
||||
tagLibrary = tl;
|
||||
}
|
||||
|
||||
/**
|
||||
* The instance of TabLibraryInfo we belong to.
|
||||
*
|
||||
* @return the tag library instance we belong to
|
||||
*/
|
||||
|
||||
public TagLibraryInfo getTagLibrary() {
|
||||
return tagLibrary;
|
||||
}
|
||||
|
||||
|
||||
// ============== JSP 2.0 TLD Information ========
|
||||
|
||||
|
||||
/**
|
||||
* Get the displayName.
|
||||
*
|
||||
* @return A short name to be displayed by tools,
|
||||
* or null if not defined
|
||||
*/
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path to the small icon.
|
||||
*
|
||||
* @return Path to a small icon to be displayed by tools,
|
||||
* or null if not defined
|
||||
*/
|
||||
|
||||
public String getSmallIcon() {
|
||||
return smallIcon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path to the large icon.
|
||||
*
|
||||
* @return Path to a large icon to be displayed by tools,
|
||||
* or null if not defined
|
||||
*/
|
||||
|
||||
public String getLargeIcon() {
|
||||
return largeIcon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get TagVariableInfo objects associated with this TagInfo.
|
||||
*
|
||||
* @return Array of TagVariableInfo objects corresponding to
|
||||
* variables declared by this tag, or a zero length
|
||||
* array if no variables have been declared
|
||||
*/
|
||||
|
||||
public TagVariableInfo[] getTagVariableInfos() {
|
||||
return tagVariableInfo;
|
||||
}
|
||||
|
||||
|
||||
// ============== JSP 2.0 TLD Information ========
|
||||
|
||||
/**
|
||||
* Get dynamicAttributes associated with this TagInfo.
|
||||
*
|
||||
* @return True if tag handler supports dynamic attributes
|
||||
* @since 2.0
|
||||
*/
|
||||
public boolean hasDynamicAttributes() {
|
||||
return dynamicAttributes;
|
||||
}
|
||||
|
||||
/*
|
||||
* private fields for 1.1 info
|
||||
*/
|
||||
private final String tagName; // the name of the tag
|
||||
private final String tagClassName;
|
||||
private final String bodyContent;
|
||||
private final String infoString;
|
||||
private TagLibraryInfo tagLibrary;
|
||||
private TagExtraInfo tagExtraInfo; // instance of TagExtraInfo
|
||||
private final TagAttributeInfo[] attributeInfo;
|
||||
|
||||
/*
|
||||
* private fields for 1.2 info
|
||||
*/
|
||||
private final String displayName;
|
||||
private final String smallIcon;
|
||||
private final String largeIcon;
|
||||
private final TagVariableInfo[] tagVariableInfo;
|
||||
|
||||
/*
|
||||
* Additional private fields for 2.0 info
|
||||
*/
|
||||
private final boolean dynamicAttributes;
|
||||
}
|
||||
286
java/javax/servlet/jsp/tagext/TagLibraryInfo.java
Normal file
286
java/javax/servlet/jsp/tagext/TagLibraryInfo.java
Normal file
@@ -0,0 +1,286 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.tagext;
|
||||
|
||||
|
||||
/**
|
||||
* Translation-time information associated with a taglib directive, and its
|
||||
* underlying TLD file. Most of the information is directly from the TLD, except
|
||||
* for the prefix and the uri values used in the taglib directive
|
||||
*/
|
||||
public abstract class TagLibraryInfo {
|
||||
|
||||
/**
|
||||
* Constructor. This will invoke the constructors for TagInfo, and
|
||||
* TagAttributeInfo after parsing the TLD file.
|
||||
*
|
||||
* @param prefix
|
||||
* the prefix actually used by the taglib directive
|
||||
* @param uri
|
||||
* the URI actually used by the taglib directive
|
||||
*/
|
||||
protected TagLibraryInfo(String prefix, String uri) {
|
||||
this.prefix = prefix;
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
// ==== methods accessing taglib information =======
|
||||
|
||||
/**
|
||||
* The value of the uri attribute from the taglib directive for this
|
||||
* library.
|
||||
*
|
||||
* @return the value of the uri attribute
|
||||
*/
|
||||
public String getURI() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* The prefix assigned to this taglib from the taglib directive
|
||||
*
|
||||
* @return the prefix assigned to this taglib from the taglib directive
|
||||
*/
|
||||
public String getPrefixString() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
// ==== methods using the TLD data =======
|
||||
|
||||
/**
|
||||
* The preferred short name (prefix) as indicated in the TLD. This may be
|
||||
* used by authoring tools as the preferred prefix to use when creating an
|
||||
* taglib directive for this library.
|
||||
*
|
||||
* @return the preferred short name for the library
|
||||
*/
|
||||
public String getShortName() {
|
||||
return shortname;
|
||||
}
|
||||
|
||||
/**
|
||||
* The "reliable" URN indicated in the TLD (the uri element). This may be
|
||||
* used by authoring tools as a global identifier to use when creating a
|
||||
* taglib directive for this library.
|
||||
*
|
||||
* @return a reliable URN to a TLD like this
|
||||
*/
|
||||
public String getReliableURN() {
|
||||
return urn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Information (documentation) for this TLD.
|
||||
*
|
||||
* @return the info string for this tag lib
|
||||
*/
|
||||
public String getInfoString() {
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* A string describing the required version of the JSP container.
|
||||
*
|
||||
* @return the (minimal) required version of the JSP container.
|
||||
* @see javax.servlet.jsp.JspEngineInfo
|
||||
*/
|
||||
public String getRequiredVersion() {
|
||||
return jspversion;
|
||||
}
|
||||
|
||||
/**
|
||||
* An array describing the tags that are defined in this tag library.
|
||||
*
|
||||
* @return the TagInfo objects corresponding to the tags defined by this tag
|
||||
* library, or a zero length array if this tag library defines no
|
||||
* tags
|
||||
*/
|
||||
public TagInfo[] getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* An array describing the tag files that are defined in this tag library.
|
||||
*
|
||||
* @return the TagFileInfo objects corresponding to the tag files defined by
|
||||
* this tag library, or a zero length array if this tag library
|
||||
* defines no tags files
|
||||
* @since 2.0
|
||||
*/
|
||||
public TagFileInfo[] getTagFiles() {
|
||||
return tagFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the TagInfo for a given tag name, looking through all the tags in
|
||||
* this tag library.
|
||||
*
|
||||
* @param shortname
|
||||
* The short name (no prefix) of the tag
|
||||
* @return the TagInfo for the tag with the specified short name, or null if
|
||||
* no such tag is found
|
||||
*/
|
||||
public TagInfo getTag(String shortname) {
|
||||
TagInfo tags[] = getTags();
|
||||
|
||||
if (tags == null || tags.length == 0 || shortname == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < tags.length; i++) {
|
||||
if (shortname.equals(tags[i].getTagName())) {
|
||||
return tags[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the TagFileInfo for a given tag name, looking through all the tag
|
||||
* files in this tag library.
|
||||
*
|
||||
* @param shortname
|
||||
* The short name (no prefix) of the tag
|
||||
* @return the TagFileInfo for the specified Tag file, or null if no Tag
|
||||
* file is found
|
||||
* @since 2.0
|
||||
*/
|
||||
public TagFileInfo getTagFile(String shortname) {
|
||||
TagFileInfo tagFiles[] = getTagFiles();
|
||||
|
||||
if (tagFiles == null || tagFiles.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < tagFiles.length; i++) {
|
||||
if (tagFiles[i].getName().equals(shortname)) {
|
||||
return tagFiles[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* An array describing the functions that are defined in this tag library.
|
||||
*
|
||||
* @return the functions defined in this tag library, or a zero length array
|
||||
* if the tag library defines no functions.
|
||||
* @since 2.0
|
||||
*/
|
||||
public FunctionInfo[] getFunctions() {
|
||||
return functions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the FunctionInfo for a given function name, looking through all the
|
||||
* functions in this tag library.
|
||||
*
|
||||
* @param name
|
||||
* The name (no prefix) of the function
|
||||
* @return the FunctionInfo for the function with the given name, or null if
|
||||
* no such function exists
|
||||
* @since 2.0
|
||||
*/
|
||||
public FunctionInfo getFunction(String name) {
|
||||
|
||||
if (functions == null || functions.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < functions.length; i++) {
|
||||
if (functions[i].getName().equals(name)) {
|
||||
return functions[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of TagLibraryInfo objects representing the entire set of
|
||||
* tag libraries (including this TagLibraryInfo) imported by taglib
|
||||
* directives in the translation unit that references this TagLibraryInfo.
|
||||
* If a tag library is imported more than once and bound to different
|
||||
* prefixes, only the TagLibraryInfo bound to the first prefix must be
|
||||
* included in the returned array.
|
||||
*
|
||||
* @return Array of TagLibraryInfo objects representing the entire set of
|
||||
* tag libraries (including this TagLibraryInfo) imported by taglib
|
||||
* directives in the translation unit that references this
|
||||
* TagLibraryInfo.
|
||||
* @since 2.1
|
||||
*/
|
||||
public abstract javax.servlet.jsp.tagext.TagLibraryInfo[] getTagLibraryInfos();
|
||||
|
||||
// Protected fields
|
||||
|
||||
/**
|
||||
* The prefix assigned to this taglib from the taglib directive.
|
||||
*/
|
||||
protected String prefix;
|
||||
|
||||
/**
|
||||
* The value of the uri attribute from the taglib directive for this
|
||||
* library.
|
||||
*/
|
||||
protected String uri;
|
||||
|
||||
/**
|
||||
* An array describing the tags that are defined in this tag library.
|
||||
*/
|
||||
protected TagInfo[] tags;
|
||||
|
||||
/**
|
||||
* An array describing the tag files that are defined in this tag library.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
protected TagFileInfo[] tagFiles;
|
||||
|
||||
/**
|
||||
* An array describing the functions that are defined in this tag library.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
protected FunctionInfo[] functions;
|
||||
|
||||
// Tag Library Data
|
||||
|
||||
/**
|
||||
* The version of the tag library.
|
||||
*/
|
||||
protected String tlibversion; // required
|
||||
|
||||
/**
|
||||
* The version of the JSP specification this tag library is written to.
|
||||
*/
|
||||
protected String jspversion; // required
|
||||
|
||||
/**
|
||||
* The preferred short name (prefix) as indicated in the TLD.
|
||||
*/
|
||||
protected String shortname; // required
|
||||
|
||||
/**
|
||||
* The "reliable" URN indicated in the TLD.
|
||||
*/
|
||||
protected String urn; // required
|
||||
|
||||
/**
|
||||
* Information (documentation) for this TLD.
|
||||
*/
|
||||
protected String info; // optional
|
||||
}
|
||||
144
java/javax/servlet/jsp/tagext/TagLibraryValidator.java
Normal file
144
java/javax/servlet/jsp/tagext/TagLibraryValidator.java
Normal file
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.tagext;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Translation-time validator class for a JSP page.
|
||||
* A validator operates on the XML view associated with the JSP page.
|
||||
*
|
||||
* <p>
|
||||
* The TLD file associates a TagLibraryValidator class and some init
|
||||
* arguments with a tag library.
|
||||
*
|
||||
* <p>
|
||||
* The JSP container is responsible for locating an appropriate
|
||||
* instance of the appropriate subclass by
|
||||
*
|
||||
* <ul>
|
||||
* <li> new a fresh instance, or reuse an available one
|
||||
* <li> invoke the setInitParams(Map) method on the instance
|
||||
* </ul>
|
||||
*
|
||||
* once initialized, the validate(String, String, PageData) method will
|
||||
* be invoked, where the first two arguments are the prefix
|
||||
* and uri for this tag library in the XML View. The prefix is intended
|
||||
* to make it easier to produce an error message. However, it is not
|
||||
* always accurate. In the case where a single URI is mapped to more
|
||||
* than one prefix in the XML view, the prefix of the first URI is provided.
|
||||
* Therefore, to provide high quality error messages in cases where the
|
||||
* tag elements themselves are checked, the prefix parameter should be
|
||||
* ignored and the actual prefix of the element should be used instead.
|
||||
* TagLibraryValidators should always use the uri to identify elements
|
||||
* as belonging to the tag library, not the prefix.
|
||||
*
|
||||
* <p>
|
||||
* A TagLibraryValidator instance
|
||||
* may create auxiliary objects internally to perform
|
||||
* the validation (e.g. an XSchema validator) and may reuse it for all
|
||||
* the pages in a given translation run.
|
||||
*
|
||||
* <p>
|
||||
* The JSP container is not guaranteed to serialize invocations of
|
||||
* validate() method, and TagLibraryValidators should perform any
|
||||
* synchronization they may require.
|
||||
*
|
||||
* <p>
|
||||
* As of JSP 2.0, a JSP container must provide a jsp:id attribute to
|
||||
* provide higher quality validation errors.
|
||||
* The container will track the JSP pages
|
||||
* as passed to the container, and will assign to each element
|
||||
* a unique "id", which is passed as the value of the jsp:id
|
||||
* attribute. Each XML element in the XML view available will
|
||||
* be extended with this attribute. The TagLibraryValidator
|
||||
* can then use the attribute in one or more ValidationMessage
|
||||
* objects. The container then, in turn, can use these
|
||||
* values to provide more precise information on the location
|
||||
* of an error.
|
||||
*
|
||||
* <p>
|
||||
* The actual prefix of the <code>id</code> attribute may or may not be
|
||||
* <code>jsp</code> but it will always map to the namespace
|
||||
* <code>http://java.sun.com/JSP/Page</code>. A TagLibraryValidator
|
||||
* implementation must rely on the uri, not the prefix, of the <code>id</code>
|
||||
* attribute.
|
||||
*/
|
||||
|
||||
public abstract class TagLibraryValidator {
|
||||
|
||||
/**
|
||||
* Sole constructor. (For invocation by subclass constructors,
|
||||
* typically implicit.)
|
||||
*/
|
||||
public TagLibraryValidator() {
|
||||
// NOOP by default
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the init data in the TLD for this validator.
|
||||
* Parameter names are keys, and parameter values are the values.
|
||||
*
|
||||
* @param map A Map describing the init parameters
|
||||
*/
|
||||
public void setInitParameters(Map<String, Object> map) {
|
||||
initParameters = map;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the init parameters data as an immutable Map.
|
||||
* Parameter names are keys, and parameter values are the values.
|
||||
*
|
||||
* @return The init parameters as an immutable map.
|
||||
*/
|
||||
public Map<String, Object> getInitParameters() {
|
||||
return initParameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a JSP page.
|
||||
* This will get invoked once per unique tag library URI in the
|
||||
* XML view. This method will return null if the page is valid; otherwise
|
||||
* the method should return an array of ValidationMessage objects.
|
||||
* An array of length zero is also interpreted as no errors.
|
||||
*
|
||||
* @param prefix the first prefix with which the tag library is
|
||||
* associated, in the XML view. Note that some tags may use
|
||||
* a different prefix if the namespace is redefined.
|
||||
* @param uri the tag library's unique identifier
|
||||
* @param page the JspData page object
|
||||
* @return A null object, or zero length array if no errors, an array
|
||||
* of ValidationMessages otherwise.
|
||||
*/
|
||||
public ValidationMessage[] validate(String prefix, String uri,
|
||||
PageData page) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Release any data kept by this instance for validation purposes.
|
||||
*/
|
||||
public void release() {
|
||||
initParameters = null;
|
||||
}
|
||||
|
||||
// Private data
|
||||
private Map<String, Object> initParameters;
|
||||
|
||||
}
|
||||
291
java/javax/servlet/jsp/tagext/TagSupport.java
Normal file
291
java/javax/servlet/jsp/tagext/TagSupport.java
Normal file
@@ -0,0 +1,291 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.tagext;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import javax.servlet.jsp.JspException;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
|
||||
/**
|
||||
* A base class for defining new tag handlers implementing Tag.
|
||||
*
|
||||
* <p> The TagSupport class is a utility class intended to be used as
|
||||
* the base class for new tag handlers. The TagSupport class
|
||||
* implements the Tag and IterationTag interfaces and adds additional
|
||||
* convenience methods including getter methods for the properties in
|
||||
* Tag. TagSupport has one static method that is included to
|
||||
* facilitate coordination among cooperating tags.
|
||||
*
|
||||
* <p> Many tag handlers will extend TagSupport and only redefine a
|
||||
* few methods.
|
||||
*/
|
||||
public class TagSupport implements IterationTag, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Find the instance of a given class type that is closest to a given
|
||||
* instance.
|
||||
* This method uses the getParent method from the Tag
|
||||
* interface.
|
||||
* This method is used for coordination among cooperating tags.
|
||||
*
|
||||
* <p>
|
||||
* The current version of the specification only provides one formal
|
||||
* way of indicating the observable type of a tag handler: its
|
||||
* tag handler implementation class, described in the tag-class
|
||||
* subelement of the tag element. This is extended in an
|
||||
* informal manner by allowing the tag library author to
|
||||
* indicate in the description subelement an observable type.
|
||||
* The type should be a subtype of the tag handler implementation
|
||||
* class or void.
|
||||
* This additional constraint can be exploited by a
|
||||
* specialized container that knows about that specific tag library,
|
||||
* as in the case of the JSP standard tag library.
|
||||
*
|
||||
* <p>
|
||||
* When a tag library author provides information on the
|
||||
* observable type of a tag handler, client programmatic code
|
||||
* should adhere to that constraint. Specifically, the Class
|
||||
* passed to findAncestorWithClass should be a subtype of the
|
||||
* observable type.
|
||||
*
|
||||
*
|
||||
* @param from The instance from where to start looking.
|
||||
* @param klass The subclass of Tag or interface to be matched
|
||||
* @return the nearest ancestor that implements the interface
|
||||
* or is an instance of the class specified
|
||||
*/
|
||||
public static final Tag findAncestorWithClass(Tag from,
|
||||
// TCK signature test fails with generics
|
||||
@SuppressWarnings("rawtypes")
|
||||
Class klass) {
|
||||
boolean isInterface = false;
|
||||
|
||||
if (from == null ||
|
||||
klass == null ||
|
||||
(!Tag.class.isAssignableFrom(klass) &&
|
||||
!(isInterface = klass.isInterface()))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
Tag tag = from.getParent();
|
||||
|
||||
if (tag == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ((isInterface && klass.isInstance(tag)) ||
|
||||
((Class<?>)klass).isAssignableFrom(tag.getClass())) {
|
||||
return tag;
|
||||
}
|
||||
from = tag;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Default constructor, all subclasses are required to define only
|
||||
* a public constructor with the same signature, and to call the
|
||||
* superclass constructor.
|
||||
*
|
||||
* This constructor is called by the code generated by the JSP
|
||||
* translator.
|
||||
*/
|
||||
public TagSupport() {
|
||||
// NOOP by default
|
||||
}
|
||||
|
||||
/**
|
||||
* Default processing of the start tag, returning SKIP_BODY.
|
||||
*
|
||||
* @return SKIP_BODY
|
||||
* @throws JspException if an error occurs while processing this tag
|
||||
*
|
||||
* @see Tag#doStartTag()
|
||||
*/
|
||||
@Override
|
||||
public int doStartTag() throws JspException {
|
||||
return SKIP_BODY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default processing of the end tag returning EVAL_PAGE.
|
||||
*
|
||||
* @return EVAL_PAGE
|
||||
* @throws JspException if an error occurs while processing this tag
|
||||
*
|
||||
* @see Tag#doEndTag()
|
||||
*/
|
||||
@Override
|
||||
public int doEndTag() throws JspException {
|
||||
return EVAL_PAGE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Default processing for a body.
|
||||
*
|
||||
* @return SKIP_BODY
|
||||
* @throws JspException if an error occurs while processing this tag
|
||||
*
|
||||
* @see IterationTag#doAfterBody()
|
||||
*/
|
||||
@Override
|
||||
public int doAfterBody() throws JspException {
|
||||
return SKIP_BODY;
|
||||
}
|
||||
|
||||
// Actions related to body evaluation
|
||||
|
||||
|
||||
/**
|
||||
* Release state.
|
||||
*
|
||||
* @see Tag#release()
|
||||
*/
|
||||
@Override
|
||||
public void release() {
|
||||
parent = null;
|
||||
id = null;
|
||||
if( values != null ) {
|
||||
values.clear();
|
||||
}
|
||||
values = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the nesting tag of this tag.
|
||||
*
|
||||
* @param t The parent Tag.
|
||||
* @see Tag#setParent(Tag)
|
||||
*/
|
||||
@Override
|
||||
public void setParent(Tag t) {
|
||||
parent = t;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Tag instance most closely enclosing this tag instance.
|
||||
* @see Tag#getParent()
|
||||
*
|
||||
* @return the parent tag instance or null
|
||||
*/
|
||||
@Override
|
||||
public Tag getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the id attribute for this tag.
|
||||
*
|
||||
* @param id The String for the id.
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* The value of the id attribute of this tag; or null.
|
||||
*
|
||||
* @return the value of the id attribute, or null
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the page context.
|
||||
*
|
||||
* @param pageContext The PageContext.
|
||||
* @see Tag#setPageContext
|
||||
*/
|
||||
@Override
|
||||
public void setPageContext(PageContext pageContext) {
|
||||
this.pageContext = pageContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Associate a value with a String key.
|
||||
*
|
||||
* @param k The key String.
|
||||
* @param o The value to associate.
|
||||
*/
|
||||
public void setValue(String k, Object o) {
|
||||
if (values == null) {
|
||||
values = new Hashtable<>();
|
||||
}
|
||||
values.put(k, o);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a the value associated with a key.
|
||||
*
|
||||
* @param k The string key.
|
||||
* @return The value associated with the key, or null.
|
||||
*/
|
||||
public Object getValue(String k) {
|
||||
if (values == null) {
|
||||
return null;
|
||||
}
|
||||
return values.get(k);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a value associated with a key.
|
||||
*
|
||||
* @param k The string key.
|
||||
*/
|
||||
public void removeValue(String k) {
|
||||
if (values != null) {
|
||||
values.remove(k);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumerate the keys for the values kept by this tag handler.
|
||||
*
|
||||
* @return An enumeration of all the keys for the values set,
|
||||
* or null or an empty Enumeration if no values have been set.
|
||||
*/
|
||||
public Enumeration<String> getValues() {
|
||||
if (values == null) {
|
||||
return null;
|
||||
}
|
||||
return values.keys();
|
||||
}
|
||||
|
||||
// private fields
|
||||
|
||||
private Tag parent;
|
||||
private Hashtable<String, Object> values;
|
||||
/**
|
||||
* The value of the id attribute of this tag; or null.
|
||||
*/
|
||||
protected String id;
|
||||
|
||||
// protected fields
|
||||
|
||||
/**
|
||||
* The PageContext.
|
||||
*/
|
||||
protected transient PageContext pageContext;
|
||||
}
|
||||
|
||||
109
java/javax/servlet/jsp/tagext/TagVariableInfo.java
Normal file
109
java/javax/servlet/jsp/tagext/TagVariableInfo.java
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.tagext;
|
||||
|
||||
/**
|
||||
* Variable information for a tag in a Tag Library; This class is instantiated
|
||||
* from the Tag Library Descriptor file (TLD) and is available only at
|
||||
* translation time. This object should be immutable. This information is only
|
||||
* available in JSP 1.2 format TLDs or above.
|
||||
*/
|
||||
public class TagVariableInfo {
|
||||
|
||||
/**
|
||||
* Constructor for TagVariableInfo.
|
||||
*
|
||||
* @param nameGiven
|
||||
* value of <name-given>
|
||||
* @param nameFromAttribute
|
||||
* value of <name-from-attribute>
|
||||
* @param className
|
||||
* value of <variable-class>
|
||||
* @param declare
|
||||
* value of <declare>
|
||||
* @param scope
|
||||
* value of <scope>
|
||||
*/
|
||||
public TagVariableInfo(String nameGiven, String nameFromAttribute,
|
||||
String className, boolean declare, int scope) {
|
||||
this.nameGiven = nameGiven;
|
||||
this.nameFromAttribute = nameFromAttribute;
|
||||
this.className = className;
|
||||
this.declare = declare;
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* The body of the <name-given> element.
|
||||
*
|
||||
* @return The variable name as a constant
|
||||
*/
|
||||
public String getNameGiven() {
|
||||
return nameGiven;
|
||||
}
|
||||
|
||||
/**
|
||||
* The body of the <name-from-attribute> element. This is the name of
|
||||
* an attribute whose (translation-time) value will give the name of the
|
||||
* variable. One of <name-given> or <name-from-attribute> is
|
||||
* required.
|
||||
*
|
||||
* @return The attribute whose value defines the variable name
|
||||
*/
|
||||
public String getNameFromAttribute() {
|
||||
return nameFromAttribute;
|
||||
}
|
||||
|
||||
/**
|
||||
* The body of the <variable-class> element.
|
||||
*
|
||||
* @return The name of the class of the variable or 'java.lang.String' if
|
||||
* not defined in the TLD.
|
||||
*/
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
/**
|
||||
* The body of the <declare> element.
|
||||
*
|
||||
* @return Whether the variable is to be declared or not. If not defined in
|
||||
* the TLD, 'true' will be returned.
|
||||
*/
|
||||
public boolean getDeclare() {
|
||||
return declare;
|
||||
}
|
||||
|
||||
/**
|
||||
* The body of the <scope> element.
|
||||
*
|
||||
* @return The scope to give the variable. NESTED scope will be returned if
|
||||
* not defined in the TLD.
|
||||
*/
|
||||
public int getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
/*
|
||||
* private fields
|
||||
*/
|
||||
private final String nameGiven; // <name-given>
|
||||
private final String nameFromAttribute; // <name-from-attribute>
|
||||
private final String className; // <class>
|
||||
private final boolean declare; // <declare>
|
||||
private final int scope; // <scope>
|
||||
}
|
||||
99
java/javax/servlet/jsp/tagext/TryCatchFinally.java
Normal file
99
java/javax/servlet/jsp/tagext/TryCatchFinally.java
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.tagext;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The auxiliary interface of a Tag, IterationTag or BodyTag tag
|
||||
* handler that wants additional hooks for managing resources.
|
||||
*
|
||||
* <p>This interface provides two new methods: doCatch(Throwable)
|
||||
* and doFinally(). The prototypical invocation is as follows:
|
||||
*
|
||||
* <pre>
|
||||
* h = get a Tag(); // get a tag handler, perhaps from pool
|
||||
*
|
||||
* h.setPageContext(pc); // initialize as desired
|
||||
* h.setParent(null);
|
||||
* h.setFoo("foo");
|
||||
*
|
||||
* // tag invocation protocol; see Tag.java
|
||||
* try {
|
||||
* doStartTag()...
|
||||
* ....
|
||||
* doEndTag()...
|
||||
* } catch (Throwable t) {
|
||||
* // react to exceptional condition
|
||||
* h.doCatch(t);
|
||||
* } finally {
|
||||
* // restore data invariants and release per-invocation resources
|
||||
* h.doFinally();
|
||||
* }
|
||||
*
|
||||
* ... other invocations perhaps with some new setters
|
||||
* ...
|
||||
* h.release(); // release long-term resources
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
public interface TryCatchFinally {
|
||||
|
||||
/**
|
||||
* Invoked if a Throwable occurs while evaluating the BODY
|
||||
* inside a tag or in any of the following methods:
|
||||
* Tag.doStartTag(), Tag.doEndTag(),
|
||||
* IterationTag.doAfterBody() and BodyTag.doInitBody().
|
||||
*
|
||||
* <p>This method is not invoked if the Throwable occurs during
|
||||
* one of the setter methods.
|
||||
*
|
||||
* <p>This method may throw an exception (the same or a new one)
|
||||
* that will be propagated further up the nest chain. If an exception
|
||||
* is thrown, doFinally() will be invoked.
|
||||
*
|
||||
* <p>This method is intended to be used to respond to an exceptional
|
||||
* condition.
|
||||
*
|
||||
* @param t The throwable exception navigating through this tag.
|
||||
* @throws Throwable if the exception is to be rethrown further up
|
||||
* the nest chain.
|
||||
*/
|
||||
|
||||
void doCatch(Throwable t) throws Throwable;
|
||||
|
||||
/**
|
||||
* Invoked in all cases after doEndTag() for any class implementing
|
||||
* Tag, IterationTag or BodyTag. This method is invoked even if
|
||||
* an exception has occurred in the BODY of the tag,
|
||||
* or in any of the following methods:
|
||||
* Tag.doStartTag(), Tag.doEndTag(),
|
||||
* IterationTag.doAfterBody() and BodyTag.doInitBody().
|
||||
*
|
||||
* <p>This method is not invoked if the Throwable occurs during
|
||||
* one of the setter methods.
|
||||
*
|
||||
* <p>This method should not throw an Exception.
|
||||
*
|
||||
* <p>This method is intended to maintain per-invocation data
|
||||
* integrity and resource management actions.
|
||||
*/
|
||||
|
||||
void doFinally();
|
||||
}
|
||||
77
java/javax/servlet/jsp/tagext/ValidationMessage.java
Normal file
77
java/javax/servlet/jsp/tagext/ValidationMessage.java
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.tagext;
|
||||
|
||||
/**
|
||||
* A validation message from either TagLibraryValidator or TagExtraInfo.
|
||||
* <p>
|
||||
* As of JSP 2.0, a JSP container must support a jsp:id attribute to provide
|
||||
* higher quality validation errors. The container will track the JSP pages as
|
||||
* passed to the container, and will assign to each element a unique "id", which
|
||||
* is passed as the value of the jsp:id attribute. Each XML element in the XML
|
||||
* view available will be extended with this attribute. The TagLibraryValidator
|
||||
* can then use the attribute in one or more ValidationMessage objects. The
|
||||
* container then, in turn, can use these values to provide more precise
|
||||
* information on the location of an error.
|
||||
* <p>
|
||||
* The actual prefix of the <code>id</code> attribute may or may not be
|
||||
* <code>jsp</code> but it will always map to the namespace
|
||||
* <code>http://java.sun.com/JSP/Page</code>. A TagLibraryValidator
|
||||
* implementation must rely on the uri, not the prefix, of the <code>id</code>
|
||||
* attribute.
|
||||
*/
|
||||
public class ValidationMessage {
|
||||
|
||||
/**
|
||||
* Create a ValidationMessage. The message String should be non-null. The
|
||||
* value of id may be null, if the message is not specific to any XML
|
||||
* element, or if no jsp:id attributes were passed on. If non-null, the
|
||||
* value of id must be the value of a jsp:id attribute for the PageData
|
||||
* passed into the validate() method.
|
||||
*
|
||||
* @param id
|
||||
* Either null, or the value of a jsp:id attribute.
|
||||
* @param message
|
||||
* A localized validation message.
|
||||
*/
|
||||
public ValidationMessage(String id, String message) {
|
||||
this.id = id;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the jsp:id. Null means that there is no information available.
|
||||
*
|
||||
* @return The jsp:id information.
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the localized validation message.
|
||||
*
|
||||
* @return A validation message
|
||||
*/
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
// Private data
|
||||
private final String id;
|
||||
private final String message;
|
||||
}
|
||||
258
java/javax/servlet/jsp/tagext/VariableInfo.java
Normal file
258
java/javax/servlet/jsp/tagext/VariableInfo.java
Normal file
@@ -0,0 +1,258 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 javax.servlet.jsp.tagext;
|
||||
|
||||
/**
|
||||
* Information on the scripting variables that are created/modified by a tag (at
|
||||
* run-time). This information is provided by TagExtraInfo classes and it is
|
||||
* used by the translation phase of JSP.
|
||||
* <p>
|
||||
* Scripting variables generated by a custom action have an associated scope of
|
||||
* either AT_BEGIN, NESTED, or AT_END.
|
||||
* <p>
|
||||
* The class name (VariableInfo.getClassName) in the returned objects is used to
|
||||
* determine the types of the scripting variables. Note that because scripting
|
||||
* variables are assigned their values from scoped attributes which cannot be of
|
||||
* primitive types, "boxed" types such as
|
||||
* <code>java.lang.Integer</code> must be used instead of primitives.
|
||||
* <p>
|
||||
* The class name may be a Fully Qualified Class Name, or a short class name.
|
||||
* <p>
|
||||
* If a Fully Qualified Class Name is provided, it should refer to a class that
|
||||
* should be in the CLASSPATH for the Web Application (see Servlet 2.4
|
||||
* specification - essentially it is WEB-INF/lib and WEB-INF/classes). Failure
|
||||
* to be so will lead to a translation-time error.
|
||||
* <p>
|
||||
* If a short class name is given in the VariableInfo objects, then the class
|
||||
* name must be that of a public class in the context of the import directives
|
||||
* of the page where the custom action appears. The class must also be in the
|
||||
* CLASSPATH for the Web Application (see Servlet 2.4 specification -
|
||||
* essentially it is WEB-INF/lib and WEB-INF/classes). Failure to be so will
|
||||
* lead to a translation-time error.
|
||||
* <p>
|
||||
* <B>Usage Comments</B>
|
||||
* <p>
|
||||
* Frequently a fully qualified class name will refer to a class that is known
|
||||
* to the tag library and thus, delivered in the same JAR file as the tag
|
||||
* handlers. In most other remaining cases it will refer to a class that is in
|
||||
* the platform on which the JSP processor is built (like J2EE). Using fully
|
||||
* qualified class names in this manner makes the usage relatively resistant to
|
||||
* configuration errors.
|
||||
* <p>
|
||||
* A short name is usually generated by the tag library based on some attributes
|
||||
* passed through from the custom action user (the author), and it is thus less
|
||||
* robust: for instance a missing import directive in the referring JSP page
|
||||
* will lead to an invalid short name class and a translation error.
|
||||
* <p>
|
||||
* <B>Synchronization Protocol</B>
|
||||
* <p>
|
||||
* The result of the invocation on getVariableInfo is an array of VariableInfo
|
||||
* objects. Each such object describes a scripting variable by providing its
|
||||
* name, its type, whether the variable is new or not, and what its scope is.
|
||||
* Scope is best described through a picture:
|
||||
* <p>
|
||||
* <IMG src="doc-files/VariableInfo-1.gif"
|
||||
* alt="NESTED, AT_BEGIN and AT_END Variable Scopes">
|
||||
* <p>
|
||||
* The JSP 2.0 specification defines the interpretation of 3 values:
|
||||
* <ul>
|
||||
* <li>NESTED, if the scripting variable is available between the start tag and
|
||||
* the end tag of the action that defines it.
|
||||
* <li>AT_BEGIN, if the scripting variable is available from the start tag of
|
||||
* the action that defines it until the end of the scope.
|
||||
* <li>AT_END, if the scripting variable is available after the end tag of the
|
||||
* action that defines it until the end of the scope.
|
||||
* </ul>
|
||||
* The scope value for a variable implies what methods may affect its value and
|
||||
* thus where synchronization is needed as illustrated by the table below.
|
||||
* <b>Note:</b> the synchronization of the variable(s) will occur <em>after</em>
|
||||
* the respective method has been called. <blockquote>
|
||||
* <table style="background-color:#999999">
|
||||
* <caption>Variable Synchronization Points</caption>
|
||||
* <tbody>
|
||||
* <tr>
|
||||
* <td valign="top" colspan="6" style="background-color:#999999">
|
||||
* <u><b>Variable Synchronization Points</b></u><br>
|
||||
* </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <th valign="top" style="background-color:#c0c0c0"> </th>
|
||||
* <th valign="top" style="background-color:#c0c0c0">doStartTag()</th>
|
||||
* <th valign="top" style="background-color:#c0c0c0">doInitBody()</th>
|
||||
* <th valign="top" style="background-color:#c0c0c0">doAfterBody()</th>
|
||||
* <th valign="top" style="background-color:#c0c0c0">doEndTag()</th>
|
||||
* <th valign="top" style="background-color:#c0c0c0">doTag()</th>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td valign="top" style="background-color:#c0c0c0"><b>Tag<br>
|
||||
* </b></td>
|
||||
* <td valign="top" style="background-color:#ffffff">AT_BEGIN, NESTED<br>
|
||||
* </td>
|
||||
* <td valign="top" style="background-color:#ffffff"><br>
|
||||
* </td>
|
||||
* <td valign="top" style="background-color:#ffffff"><br>
|
||||
* </td>
|
||||
* <td valign="top" style="background-color:#ffffff">AT_BEGIN, AT_END<br>
|
||||
* </td>
|
||||
* <td valign="top" style="background-color:#ffffff"><br>
|
||||
* </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td valign="top" style="background-color:#c0c0c0"><b>IterationTag<br>
|
||||
* </b></td>
|
||||
* <td valign="top" style="background-color:#ffffff">AT_BEGIN, NESTED<br>
|
||||
* </td>
|
||||
* <td valign="top" style="background-color:#ffffff"><br>
|
||||
* </td>
|
||||
* <td valign="top" style="background-color:#ffffff">AT_BEGIN, NESTED<br>
|
||||
* </td>
|
||||
* <td valign="top" style="background-color:#ffffff">AT_BEGIN, AT_END<br>
|
||||
* </td>
|
||||
* <td valign="top" style="background-color:#ffffff"><br>
|
||||
* </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td valign="top" style="background-color:#c0c0c0"><b>BodyTag<br>
|
||||
* </b></td>
|
||||
* <td valign="top" style="background-color:#ffffff">AT_BEGIN,
|
||||
* NESTED<sup>1</sup><br>
|
||||
* </td>
|
||||
* <td valign="top" style="background-color:#ffffff">AT_BEGIN,
|
||||
* NESTED<sup>1</sup><br>
|
||||
* </td>
|
||||
* <td valign="top" style="background-color:#ffffff">AT_BEGIN, NESTED<br>
|
||||
* </td>
|
||||
* <td valign="top" style="background-color:#ffffff">AT_BEGIN, AT_END<br>
|
||||
* </td>
|
||||
* <td valign="top" style="background-color:#ffffff"><br>
|
||||
* </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td valign="top" style="background-color:#c0c0c0"><b>SimpleTag<br>
|
||||
* </b></td>
|
||||
* <td valign="top" style="background-color:#ffffff"><br>
|
||||
* </td>
|
||||
* <td valign="top" style="background-color:#ffffff"><br>
|
||||
* </td>
|
||||
* <td valign="top" style="background-color:#ffffff"><br>
|
||||
* </td>
|
||||
* <td valign="top" style="background-color:#ffffff"><br>
|
||||
* </td>
|
||||
* <td valign="top" style="background-color:#ffffff">AT_BEGIN, AT_END<br>
|
||||
* </td>
|
||||
* </tr>
|
||||
* </tbody>
|
||||
* </table>
|
||||
* <sup>1</sup> Called after <code>doStartTag()</code> if
|
||||
* <code>EVAL_BODY_INCLUDE</code> is returned, or after
|
||||
* <code>doInitBody()</code> otherwise. </blockquote>
|
||||
* <p>
|
||||
* <B>Variable Information in the TLD</B>
|
||||
* <p>
|
||||
* Scripting variable information can also be encoded directly for most cases
|
||||
* into the Tag Library Descriptor using the <variable> subelement of the
|
||||
* <tag> element. See the JSP specification.
|
||||
*/
|
||||
public class VariableInfo {
|
||||
|
||||
/**
|
||||
* Scope information that scripting variable is visible only within the
|
||||
* start/end tags.
|
||||
*/
|
||||
public static final int NESTED = 0;
|
||||
|
||||
/**
|
||||
* Scope information that scripting variable is visible after start tag.
|
||||
*/
|
||||
public static final int AT_BEGIN = 1;
|
||||
|
||||
/**
|
||||
* Scope information that scripting variable is visible after end tag.
|
||||
*/
|
||||
public static final int AT_END = 2;
|
||||
|
||||
/**
|
||||
* Constructor These objects can be created (at translation time) by the
|
||||
* TagExtraInfo instances.
|
||||
*
|
||||
* @param varName
|
||||
* The name of the scripting variable
|
||||
* @param className
|
||||
* The type of this variable
|
||||
* @param declare
|
||||
* If true, it is a new variable (in some languages this will
|
||||
* require a declaration)
|
||||
* @param scope
|
||||
* Indication on the lexical scope of the variable
|
||||
*/
|
||||
public VariableInfo(String varName, String className, boolean declare,
|
||||
int scope) {
|
||||
this.varName = varName;
|
||||
this.className = className;
|
||||
this.declare = declare;
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
// Accessor methods
|
||||
|
||||
/**
|
||||
* Returns the name of the scripting variable.
|
||||
*
|
||||
* @return the name of the scripting variable
|
||||
*/
|
||||
public String getVarName() {
|
||||
return varName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of this variable.
|
||||
*
|
||||
* @return the type of this variable
|
||||
*/
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this is a new variable. If so, in some languages this
|
||||
* will require a declaration.
|
||||
*
|
||||
* @return whether this is a new variable.
|
||||
*/
|
||||
public boolean getDeclare() {
|
||||
return declare;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the lexical scope of the variable.
|
||||
*
|
||||
* @return the lexical scope of the variable, either AT_BEGIN, AT_END, or
|
||||
* NESTED.
|
||||
* @see #AT_BEGIN
|
||||
* @see #AT_END
|
||||
* @see #NESTED
|
||||
*/
|
||||
public int getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
// == private data
|
||||
private final String varName;
|
||||
private final String className;
|
||||
private final boolean declare;
|
||||
private final int scope;
|
||||
}
|
||||
BIN
java/javax/servlet/jsp/tagext/doc-files/BodyTagProtocol.gif
Normal file
BIN
java/javax/servlet/jsp/tagext/doc-files/BodyTagProtocol.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.5 KiB |
BIN
java/javax/servlet/jsp/tagext/doc-files/IterationTagProtocol.gif
Normal file
BIN
java/javax/servlet/jsp/tagext/doc-files/IterationTagProtocol.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.7 KiB |
BIN
java/javax/servlet/jsp/tagext/doc-files/TagProtocol.gif
Normal file
BIN
java/javax/servlet/jsp/tagext/doc-files/TagProtocol.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.1 KiB |
BIN
java/javax/servlet/jsp/tagext/doc-files/VariableInfo-1.gif
Normal file
BIN
java/javax/servlet/jsp/tagext/doc-files/VariableInfo-1.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
47
java/javax/servlet/jsp/tagext/package.html
Normal file
47
java/javax/servlet/jsp/tagext/package.html
Normal file
@@ -0,0 +1,47 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
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
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
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.
|
||||
-->
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
Classes and interfaces for the definition of JavaServer Pages Tag Libraries.
|
||||
|
||||
<p>
|
||||
The JavaServer Pages(tm) (JSP) 2.0 specification provides a portable
|
||||
mechanism for the description of tag libraries.
|
||||
<p>
|
||||
A JSP tag library contains
|
||||
<ul>
|
||||
<li>A Tag Library Descriptor</li>
|
||||
<li>A number of Tag Files or Tag handler classes defining
|
||||
request-time behavior</li>
|
||||
<li>Additional classes and resources used at runtime</li>
|
||||
<li>Possibly some additional classes to provide extra translation
|
||||
information</li>
|
||||
</ul>
|
||||
<p>
|
||||
The JSP 2.0 specification and the reference implementation both contain
|
||||
simple and moderately complex examples of actions defined using this
|
||||
mechanism. These are available at JSP's web site, at
|
||||
<a href="http://java.sun.com/products/jsp">http://java.sun.com/products/jsp</a>.
|
||||
Some readers may want to consult those to get a quick feel for how
|
||||
the mechanisms work together.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user