- See Also:
- Top Examples, Source Code,
Servlet.getServletConfig()
,
ServletConfig.getServletContext()
public Object getAttribute(String name)
- See Also:
getAttributeNames()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[221]Get last modified time of struts-config.xml
By Anonymous on 2005/05/25 19:31:03 Rate
long getLastModifiedTime ( ) {
String path = getServletContext ( ) .getRealPath ( "struts-config.xml" ) ;
System.out.println ( path ) ;
File file = new File ( path ) ;
return file.lastModified ( ) ;
}
//getAttribute
public Enumeration getAttributeNames()
- See Also:
getAttribute(java.lang.String)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public ServletContext getContext(String uripath)
- See Also:
RequestDispatcher
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[591]Get context
By nhu an on 2005/07/21 21:23:44 Rate
ServletContext sc=getContext ( "/ABC/encode" ) ;
public String getInitParameter(String name)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public Enumeration getInitParameterNames()
- See Also:
ServletConfig.getInitParameter(java.lang.String)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public int getMajorVersion()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public String getMimeType(String file)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public int getMinorVersion()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public RequestDispatcher getNamedDispatcher(String name)
- See Also:
ServletConfig.getServletName()
, getContext(java.lang.String)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public String getRealPath(String path)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[1020]Use getRealPath within Struts Action
By Anonymous on 2004/10/06 10:25:12 Rate
for Struts Action use:
getServlet ( ) .getServletContext ( ) .getRealPath ( "/" )
public RequestDispatcher getRequestDispatcher(String path)
- See Also:
getContext(java.lang.String)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[181]JSP forward
By Anonymous on 2003/03/14 18:12:46 Rate
public class extends HttpServlet {
protected void doPost ( HttpServletRequest req,
HttpServletResponse res ) throws... {
String creditCard = req.getParameter ( "creditCard" ) ;
String jspPage = "/process" + creditCard + ".jsp";
ServletContext sc = getServletContext ( ) ;
RequestDispatcher rd = getRequestDispatcher ( jspPage ) ;
rd.forward ( req, res ) ;
}
}
[593]_
By nhu_an_54 { at } yahoo { dot } com on 2003/12/30 02:09:04 Rate
public class extends HttpServlet {
protected void doPost ( HttpServletRequest req,
HttpServletResponse res ) throws... {
String servletPage = "/ABC/fileservlet";
ServletContext sc = getServletContext ( ) ;
RequestDispatcher rd = getRequestDispatcher ( servletPage ) ;
rd.forward ( req, res ) ;
}
}
public URL getResource(String path)
throws MalformedURLException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[443]Use default dispatcher to forward
By Anonymous on 2004/12/03 05:29:03 Rate
ServletContext cntx = getServletContext ( ) ;
URL resource = cntx.getResource ( request.getPathInfo ( ) ) ;
if ( resource != null ) { // physical file exists
RequestDispatcher rd = cntx.getNamedDispatcher ( "default" ) ;
rd.forward ( request, response ) ;
return;
}
public InputStream getResourceAsStream(String path)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[1148]Check to see if a resource was requested
By N { dot } Paul on 2004/12/03 05:09:16 Rate
//check to see if a resource was requested
String resource = request.getParameter ( "resource" ) ;
if ( resource != null && !resource.equals ( "" ) ) {
//use getResourceAsStream ( ) to properly get the file.
InputStream is = getServletContext ( ) .getResourceAsStream ( resource ) ;
if ( is != null ) { // the resource exists
response.setContentType ( "text/plain" ) ;
StringWriter sw = new StringWriter ( ) ;
for ( int c = is.read ( ) ; c != -1; c = is.read ( ) ) {
sw.write ( c ) ;
}
out.print ( sw.toString ( ) ) ;
}
}
public Set getResourcePaths(String path)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public String getServerInfo()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public Servlet getServlet(String name)
throws ServletException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public String getServletContextName()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public Enumeration getServletNames()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public Enumeration getServlets()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void log(Exception exception,
String msg)
- See Also:
log(String message, Throwable throwable)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void log(String msg)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void log(String message,
Throwable throwable)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void removeAttribute(String name)
- See Also:
getAttribute(java.lang.String)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setAttribute(String name,
Object object)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples