本文整理汇总了Java中javax.servlet.ServletException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java ServletException.getMessage方法的具体用法?Java ServletException.getMessage怎么用?Java ServletException.getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.servlet.ServletException
的用法示例。
在下文中一共展示了ServletException.getMessage方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loginUser
import javax.servlet.ServletException; //导入方法依赖的package包/类
void loginUser(VOUser voUser, String password,
HttpServletRequest httpRequest, HttpSession session)
throws LoginException, CommunicationException {
ServiceAccess serviceAccess = ServiceAccess
.getServiceAcccessFor(session);
IdentityService service = getIdService();
// authenticate the user
httpRequest.getSession();
try {
httpRequest.login(String.valueOf(voUser.getKey()), password);
} catch (ServletException e) {
throw new LoginException(e.getMessage());
}
serviceAccess.login(voUser, password, httpRequest, getResponse());
// log info on the successful login
logger.logInfo(Log4jLogger.ACCESS_LOG,
LogMessageIdentifier.INFO_USER_LOGIN_SUCCESS,
voUser.getUserId(), IPResolver.resolveIpAddress(httpRequest),
voUser.getTenantId());
// read the user details value object and store it in the session
session.setAttribute(Constants.SESS_ATTR_USER,
service.getCurrentUserDetails());
}
示例2: dispatch
import javax.servlet.ServletException; //导入方法依赖的package包/类
@Override
public void dispatch(final String path) throws IOException, FacesException
{
_checkRequest();
_checkResponse();
final RequestDispatcher requestDispatcher = _servletRequest.getRequestDispatcher(path);
// If there is no dispatcher, send NOT_FOUND
if (requestDispatcher == null)
{
if (_httpServletResponse != null)
{
_httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND);
}
return;
}
try
{
requestDispatcher.forward(_servletRequest, _servletResponse);
}
catch (final ServletException e)
{
if (e.getMessage() != null)
{
throw new FacesException(e.getMessage(), e);
}
else
{
throw new FacesException(e);
}
}
}
示例3: getFileText
import javax.servlet.ServletException; //导入方法依赖的package包/类
public String getFileText( String originalPath, boolean virtual ) throws IOException {
try {
ServletContextAndPath csAndP = getServletContextAndPath( originalPath, virtual );
ServletContext context = csAndP.getServletContext();
String path = csAndP.getPath();
RequestDispatcher rd =
context.getRequestDispatcher( path );
if ( rd == null ) {
throw new IOException("Couldn't get request dispatcher for path: " + path );
}
ByteArrayServletOutputStream basos = new ByteArrayServletOutputStream();
ResponseIncludeWrapper responseIncludeWrapper =
new ResponseIncludeWrapper(res, basos );
rd.include(req, responseIncludeWrapper );
//We can't assume the included servlet flushed its output
responseIncludeWrapper.flushOutputStreamOrWriter();
byte[] bytes = basos.toByteArray();
//Assume that the default encoding is what was used to encode the bytes. Questionable.
String retVal = new String( bytes );
//make an assumption that an empty response is a failure. This is a problem if a truly empty file
//were included, but not sure how else to tell.
if ( retVal.equals("") ) {
throw new IOException("Couldn't find file: " + path );
}
return retVal;
} catch (ServletException e) {
throw new IOException("Couldn't include file: " + originalPath + " because of ServletException: " + e.getMessage() );
}
}
示例4: getFileText
import javax.servlet.ServletException; //导入方法依赖的package包/类
@Override
public String getFileText(String originalPath, boolean virtual) throws IOException {
try {
ServletContextAndPath csAndP = getServletContextAndPath(originalPath, virtual);
ServletContext context = csAndP.getServletContext();
String path = csAndP.getPath();
RequestDispatcher rd = context.getRequestDispatcher(path);
if (rd == null) {
throw new IOException("Couldn't get request dispatcher for path: " + path);
}
ByteArrayServletOutputStream basos = new ByteArrayServletOutputStream();
ResponseIncludeWrapper responseIncludeWrapper = new ResponseIncludeWrapper(context, req, res, basos);
rd.include(req, responseIncludeWrapper);
// We can't assume the included servlet flushed its output
responseIncludeWrapper.flushOutputStreamOrWriter();
byte[] bytes = basos.toByteArray();
// Assume platform default encoding unless otherwise specified
String retVal;
if (inputEncoding == null) {
retVal = new String(bytes);
} else {
retVal = new String(bytes, B2CConverter.getCharset(inputEncoding));
}
// make an assumption that an empty response is a failure. This is
// a problem
// if a truly empty file
// were included, but not sure how else to tell.
if (retVal.equals("") && !req.getMethod().equalsIgnoreCase(org.apache.coyote.http11.Constants.HEAD)) {
throw new IOException("Couldn't find file: " + path);
}
return retVal;
} catch (ServletException e) {
throw new IOException(
"Couldn't include file: " + originalPath + " because of ServletException: " + e.getMessage());
}
}
示例5: getFileText
import javax.servlet.ServletException; //导入方法依赖的package包/类
@Override
public String getFileText(String originalPath, boolean virtual)
throws IOException {
try {
ServletContextAndPath csAndP = getServletContextAndPath(
originalPath, virtual);
ServletContext context = csAndP.getServletContext();
String path = csAndP.getPath();
RequestDispatcher rd = context.getRequestDispatcher(path);
if (rd == null) {
throw new IOException(
"Couldn't get request dispatcher for path: " + path);
}
ByteArrayServletOutputStream basos =
new ByteArrayServletOutputStream();
ResponseIncludeWrapper responseIncludeWrapper =
new ResponseIncludeWrapper(context, req, res, basos);
rd.include(req, responseIncludeWrapper);
//We can't assume the included servlet flushed its output
responseIncludeWrapper.flushOutputStreamOrWriter();
byte[] bytes = basos.toByteArray();
//Assume platform default encoding unless otherwise specified
String retVal;
if (inputEncoding == null) {
retVal = new String( bytes );
} else {
retVal = new String (bytes,
B2CConverter.getCharset(inputEncoding));
}
//make an assumption that an empty response is a failure. This is
// a problem
// if a truly empty file
//were included, but not sure how else to tell.
if (retVal.equals("") && !req.getMethod().equalsIgnoreCase(
org.apache.coyote.http11.Constants.HEAD)) {
throw new IOException("Couldn't find file: " + path);
}
return retVal;
} catch (ServletException e) {
throw new IOException("Couldn't include file: " + originalPath
+ " because of ServletException: " + e.getMessage());
}
}
示例6: getFileText
import javax.servlet.ServletException; //导入方法依赖的package包/类
public String getFileText(String originalPath, boolean virtual)
throws IOException {
try {
ServletContextAndPath csAndP = getServletContextAndPath(
originalPath, virtual);
ServletContext context = csAndP.getServletContext();
String path = csAndP.getPath();
RequestDispatcher rd = context.getRequestDispatcher(path);
if (rd == null) {
throw new IOException(
"Couldn't get request dispatcher for path: " + path);
}
ByteArrayServletOutputStream basos =
new ByteArrayServletOutputStream();
ResponseIncludeWrapper responseIncludeWrapper =
new ResponseIncludeWrapper(context, req, res, basos);
rd.include(req, responseIncludeWrapper);
//We can't assume the included servlet flushed its output
responseIncludeWrapper.flushOutputStreamOrWriter();
byte[] bytes = basos.toByteArray();
//Assume platform default encoding unless otherwise specified
String retVal;
if (inputEncoding == null) {
retVal = new String( bytes );
} else {
retVal = new String (bytes, inputEncoding);
}
//make an assumption that an empty response is a failure. This is
// a problem
// if a truly empty file
//were included, but not sure how else to tell.
if (retVal.equals("") && !req.getMethod().equalsIgnoreCase(
org.apache.coyote.http11.Constants.HEAD)) {
throw new IOException("Couldn't find file: " + path);
}
return retVal;
} catch (ServletException e) {
throw new IOException("Couldn't include file: " + originalPath
+ " because of ServletException: " + e.getMessage());
}
}