Class PageImpl
- All Implemented Interfaces:
- Page
- 
Field SummaryFieldsFields inherited from interface PageDEFAULT_BUFFER_SIZE, DEFAULT_ENCODING, DEFAULT_MIME_TYPE, DEFAULT_SRC_ENCODING, PACKAGE_NAME
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionfinal voidPrints a debug statement if debugging is turned on for this page.final voidfinal voidfinal voidvoidclientRedirect(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res, String newLocation) Redirects the client to the new page location.final voiddbg(boolean val) Starts/stop debugging with no dbg_prefix/dbg_suffix.final voidSets the prefix for debugging output.final voidSets the suffix for debugging output.final voidPrints a debug statement if debugging is turned on for this page.final voidfinal voidfinal voidvoiddestroy()This method is invoked whenever a page is destoryed/unloadedgetPagePath(jakarta.servlet.http.HttpServletRequest req) Returns the path to this page from the web servers document root.getRealPath(jakarta.servlet.http.HttpServletRequest req) Returns the real absolute directory path for thePagePath.Returns a thread specific CharArrayWriter that can be passed to this method as various points in the page.final longgetTime()Returns the time elapsed after invokingmethod (in milliseconds)invalid referencestartTimevoidinit(PageServlet servlet, String contextRelativePagePath) This method is invoked whenever a page is created and before it is run.voidrender(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res) final voidIf set to true, a timer to calculate page render time is started after this method call.
- 
Field Details- 
logThe default application log, retrieved viaWebApp.getAppLog. All molly pages can use this variable directly, for examplelog.info("test"). The log output level (and hence whether a logging statement at that level will be seen) is set by the WebApp configuration file. (If WebApp is not used or configured, then the log level will be set to theLog.DEFAULT_LEVEL)
 
- 
- 
Constructor Details- 
PageImplpublic PageImpl()
 
- 
- 
Method Details- 
render
- 
initpublic void init(PageServlet servlet, String contextRelativePagePath) throws jakarta.servlet.ServletException Description copied from interface:PageThis method is invoked whenever a page is created and before it is run.Pages should override this method to instantiate/set-up page variables as needed. (pages have no-arg constructors so like most of the servlet API, setup and initialization of variables is done in a init method instead). When overriding this class, you must remember to call: super.init The page class is reloaded if the page is modified. Variables should therefore be cleaned up in the method as needed.invalid referencedestory
- 
destroy
- 
getPagePathDescription copied from interface:PageReturns the path to this page from the web servers document root.So for example, if the page is at foo/bar.mpand is running under the webapp context ofcontext1, then the page path will be:/context1/foo/bar.mp. If there is no specific web app (i.e., the most common case of a default "" webapp), then the page path will be/foo/bar.mpThis page path is essentially what needs to be typed in the browsers URL window to invoke the page. It's also useful as form action parameters. For example, in a molly page: 
 This will submit the form to the same page where the form is defined. This can be hard coded of course but by using.. <form action="[=getPagePath(req)]" method="post"> .. </form> getPagePath, the html does not have to be changed if the name of the page changes on disk.- Specified by:
- getPagePathin interface- Page
 
- 
getRealPathDescription copied from interface:PageReturns the real absolute directory path for thePagePath.So, for example, for a webserver document root at /web/sites/default/and a page located infoo/bar.mp, the real path will be:/web/sites/default/foo/bar.mp- Specified by:
- getRealPathin interface- Page
 
- 
clientRedirectpublic void clientRedirect(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res, String newLocation) throws IOException Description copied from interface:PageRedirects the client to the new page location. This is a thin (possibly easier to remember) wrapper around themethod.invalid referenceHttpServletResponse.sendRedirectThe location parameter can be relative to the specified request's URI or relative to the context root if it contains a leading '/'. The webapp name (if any) does not have to be specified, the redirect will creates a full URL (including the webapp context path) suitable for this purpose. For example: webapp context current page location parameter resulting page default web app ("/") foo/bar.mp baz.mp foo/baz.mp default web app ("/") foo/bar.mp /baz.mp baz.mp /myapp foo/bar.mp baz.mp /myapp/foo/baz.mp /myapp foo/bar.mp /baz.mp /myapp/baz.mp - Specified by:
- clientRedirectin interface- Page
- Parameters:
- req- the current request
- res- the current response
- Throws:
- IOException
 
- 
getThreadLocalWriterDescription copied from interface:PageReturns a thread specific CharArrayWriter that can be passed to this method as various points in the page. The contents of this writer can then be printed on the page when desired.Note: The writer is not reset or flushed when it is retrieved. It must be reset manually via calling the CharArrayWriter.reset()method. This design-decision allows request threads to collect debugging data across multiple pages.The suggested usage idiom is: dbg(true); CharArrayWriter cw = getThreadLocalWriter(): bug(cw, "some message"); ... bug(cw, "other message"); ... cw.writeTo(out); cw.reset(); - Specified by:
- getThreadLocalWriterin interface- Page
 
- 
startTimerIf set to true, a timer to calculate page render time is started after this method call. Page render time can then be displaying the value returned by invoking thegetTime()method.
- 
getTimeReturns the time elapsed after invokingmethod (in milliseconds)invalid referencestartTime
- 
dbgStarts/stop debugging with no dbg_prefix/dbg_suffix.- Parameters:
- val- true to enable debugging, false to disable.
 
- 
dbgPrefix
- 
dbgSuffix
- 
bugPrints a debug statement if debugging is turned on for this page.Typically the implicit page printwriter (the outvariable) will be passed to this method and debug statements will be printed at the point where they are lexically invoked at the page.However, each page request thread can collect debugging information and print the output at some arbitrary location, such as the bottom of the page. The method getThreadLocalWriter()exists for this reason and can be used to collect thread-local output during page execution.- Throws:
- IOException
 
- 
bug- Throws:
- IOException
 
- 
bug- Throws:
- IOException
 
- 
bugpublic final void bug(Writer writer, Object str1, Object str2, Object str3, Object... args) throws IOException - Throws:
- IOException
 
- 
debugPrints a debug statement if debugging is turned on for this page. Same as callingbug(Writer, Object).- Throws:
- IOException
 
- 
debug- Throws:
- IOException
 
- 
debug- Throws:
- IOException
 
- 
debugpublic final void debug(Writer writer, Object str1, Object str2, Object str3, Object... args) throws IOException - Throws:
- IOException
 
 
-