?? webcontext.java
字號:
/*
* Copyright 2005 Joe Walker
*
* Licensed 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 org.directwebremoting;
import java.io.IOException;
import java.util.Collection;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
* Class to enable us to access servlet parameters.
* @author Joe Walker [joe at getahead dot ltd dot uk]
*/
public interface WebContext
{
/**
* Get the script session that represents the currently viewed page in the
* same way that an HttpSession represents a cookie.
* @return A browser object for this user
*/
ScriptSession getScriptSession();
/**
* Get a list of all ScriptSessions on a given page.
* Note that the list of known sessions is continually changing so it is
* possible that the list will be out of date by the time it is used. For
* this reason you should check that getScriptSession(String id) returns
* something non null.
* @param url The URL including 'http://', up to (but not including) '?' or '#'
* @return A collection of all the ScriptSessions.
*/
Collection getScriptSessionsByPage(String url);
/**
* What is the URL of the current page.
* This includes 'http://', up to (but not including) '?' or '#'
* @return The URL of the current page
*/
String getCurrentPage();
/**
* Get a list of all the ScriptSessions known to this server at the given
* time.
* Note that the list of known sessions is continually changing so it is
* possible that the list will be out of date by the time it is used. For
* this reason you should check that getScriptSession(String id) returns
* something non null.
* @return A collection of all the ScriptSessions.
*/
Collection getAllScriptSessions();
/**
* Returns the current session associated with this request, or if the
* request does not have a session, creates one.
* @return Returns the http session.
* @see HttpServletRequest#getSession()
*/
HttpSession getSession();
/**
* Returns the current HttpSession associated with this request or, if
* there is no current session and create is true, returns a new session.
* If create is false and the request has no valid HttpSession, this method
* returns null.
* @param create false to return null if there's no current session
* @return the session associated with this request
* @see HttpServletRequest#getSession(boolean)
*/
HttpSession getSession(boolean create);
/**
* Accessor for the servlet config.
* @return Returns the config.
*/
ServletConfig getServletConfig();
/**
* Returns the ServletContext to which this session belongs.
* @return The servlet context information.
*/
ServletContext getServletContext();
/**
* Accessor for the http request information.
* @return Returns the request.
*/
HttpServletRequest getHttpServletRequest();
/**
* Accessor for the http response bean.
* @return Returns the response.
*/
HttpServletResponse getHttpServletResponse();
/**
* Accessor for the IoC container.
* @return The IoC container that created the interface implementations.
*/
Container getContainer();
/**
* An attribute used by {@link WebContext#forwardToString(String)} to inform
* anyone that wants to know that this is a request from DWR.
*/
public static final String ATTRIBUTE_DWR = "org.directwebremoting"; //$NON-NLS-1$
/**
* Forward a request to a given URL and catch the data written to it.
* It is possible to distinguish requests that arrive normally and requests
* that come from a DWR forwardToString() by the presence of a request
* attribute. Before the request is forwarded, DWR will call:
* <pre>
* request.setAttribute(WebContext.ATTRIBUTE_DWR, Boolean.TRUE);
* </pre>
* @param url The URL to forward to
* @return The text that results from forwarding to the given URL
* @throws IOException if the target resource throws this exception
* @throws ServletException if the target resource throws this exception
* @throws IllegalStateException if the response was already committed
*/
String forwardToString(String url) throws ServletException, IOException;
/**
* Attempt to convert from a Java object to a Javascript expression for
* passing to eval in a browser.
* @param data The object to convert
* @return An outbound variable (contains an init code and an assign code)
* @throws MarshallException
*/
OutboundVariable toJavascript(Object data) throws MarshallException;
/**
* Fish the version number out of the dwr.properties file.
* @return The current version number.
*/
String getVersion();
/**
* For system use only: This method allows the system to fill in the session
* id and page id when they are discovered.
* @param page The URL of the current page
* @param scriptSessionId The session id passed in by the browser
*/
void setCurrentPageInformation(String page, String scriptSessionId);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -