Cannot a get JSP page instance from a page being destroyed

We have a J2EE app, using Struts + Tiles (build 1.1-b3), running on Win2KPro, Ora9ias v9.0.3. The application is roles-based, and different users see different versions of the same page based on their role authorizations. Occasionally, when multiple users in different roles are requesting the same page, the app returns the following exception:
OracleJSP:
JSP Error:
Request URI:/fast/WEB-INF/jsp/tiles/layouts/baseLayout.jsp
Exception:
javax.servlet.ServletException: Cannot a get JSP page instance from a page being destroyed
     at oracle.jsp.runtimev2.JspPageInstFacade.getInstance(JspPageInstFacade.java:147)
     at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:303)
     at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
     at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
     at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
     at oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java:283)
     at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:16)
     at com.gal.fast.portal.web.SessionInitializedFilter.doFilter(SessionInitializedFilter.java:105)
     at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:556)
     at com.evermind.server.http.ServletRequestDispatcher.include(ServletRequestDispatcher.java:119)
     at org.apache.struts.tiles.TilesUtilStrutsModulesImpl.doInclude(TilesUtilStrutsModulesImpl.java:124)
     at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:161)
     at org.apache.struts.taglib.tiles.InsertTag.doInclude(InsertTag.java:703)
     at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:818)
     at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:467)
     at web2d_inf._jsp._tiles._layouts._baseLayout._jspService(_baseLayout.java:445)
     [SRC:/WEB-INF/jsp/tiles/layouts/baseLayout.jsp:149]
     at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
     at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
     at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
     at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
     at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
     at oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java:283)
     at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:16)
     at com.gal.fast.portal.web.SessionInitializedFilter.doFilter(SessionInitializedFilter.java:105)
     at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:556)
     at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
     at com.evermind.server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:209)
     at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1033)
     at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:269)
     at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(TilesRequestProcessor.java:249)
     at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:303)
     at org.apache.struts.action.RequestProcessor.processActionForward(RequestProcessor.java:401)
     at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
     at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1422)
     at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:505)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
     at com.gal.fast.portal.web.FastActionServlet.service(FastActionServlet.java:110)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
     at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
     at oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java:283)
     at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:16)
     at com.gal.fast.portal.web.SessionInitializedFilter.doFilter(SessionInitializedFilter.java:105)
     at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:556)
     at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
     at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
     at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:148)
     at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:72)
     at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
     at java.lang.Thread.run(Thread.java:536)
All the code in the two custom classes above ( com.gal.fast.portal.web.SessionInitializedFilter and com.gal.fast.portal.web.FastActionServlet ) has been commented out to the point that they are NOOP stubs.
We only see this with multiple near-simultaneous requests for the same page with differet roles. It smells like a threading issue to me, but I'm no expert (hence this post). Any thoughts?
--matt

We have a J2EE app, using Struts + Tiles (build 1.1-b3), running on Win2KPro, Ora9ias v9.0.3. The application is roles-based, and different users see different versions of the same page based on their role authorizations. Occasionally, when multiple users in different roles are requesting the same page, the app returns the following exception:
OracleJSP:
JSP Error:
Request URI:/fast/WEB-INF/jsp/tiles/layouts/baseLayout.jsp
Exception:
javax.servlet.ServletException: Cannot a get JSP page instance from a page being destroyed
     at oracle.jsp.runtimev2.JspPageInstFacade.getInstance(JspPageInstFacade.java:147)
     at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:303)
     at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
     at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
     at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
     at oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java:283)
     at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:16)
     at com.gal.fast.portal.web.SessionInitializedFilter.doFilter(SessionInitializedFilter.java:105)
     at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:556)
     at com.evermind.server.http.ServletRequestDispatcher.include(ServletRequestDispatcher.java:119)
     at org.apache.struts.tiles.TilesUtilStrutsModulesImpl.doInclude(TilesUtilStrutsModulesImpl.java:124)
     at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:161)
     at org.apache.struts.taglib.tiles.InsertTag.doInclude(InsertTag.java:703)
     at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:818)
     at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:467)
     at web2d_inf._jsp._tiles._layouts._baseLayout._jspService(_baseLayout.java:445)
     [SRC:/WEB-INF/jsp/tiles/layouts/baseLayout.jsp:149]
     at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
     at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
     at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
     at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
     at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
     at oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java:283)
     at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:16)
     at com.gal.fast.portal.web.SessionInitializedFilter.doFilter(SessionInitializedFilter.java:105)
     at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:556)
     at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
     at com.evermind.server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:209)
     at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1033)
     at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:269)
     at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(TilesRequestProcessor.java:249)
     at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:303)
     at org.apache.struts.action.RequestProcessor.processActionForward(RequestProcessor.java:401)
     at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
     at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1422)
     at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:505)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
     at com.gal.fast.portal.web.FastActionServlet.service(FastActionServlet.java:110)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
     at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
     at oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java:283)
     at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:16)
     at com.gal.fast.portal.web.SessionInitializedFilter.doFilter(SessionInitializedFilter.java:105)
     at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:556)
     at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
     at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
     at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:148)
     at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:72)
     at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
     at java.lang.Thread.run(Thread.java:536)
All the code in the two custom classes above ( com.gal.fast.portal.web.SessionInitializedFilter and com.gal.fast.portal.web.FastActionServlet ) has been commented out to the point that they are NOOP stubs.
We only see this with multiple near-simultaneous requests for the same page with differet roles. It smells like a threading issue to me, but I'm no expert (hence this post). Any thoughts?
--matt

Similar Messages

  • Getting JSP Page

    Hi
    Can someone tell me how to write a java program which gets a jsp page that is hosted on a server.
    I need to write a program to make 1000 simultaneous requests to the appserver and get the jsp page. Something like load testing the program.
    Thanks
    nemogill

    well i can get you the code to retrieve the source code of the page.
    Well but i don't think you can make 1000 simultaneous requests.
    Code is :
    import java.io.BufferedReader;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.IOException;
    import java.io.OutputStream;
    import java.io.PrintWriter;
    import java.net.HttpURLConnection;
    import java.net.URL;
    import java.net.URLConnection;
    public class URLGet
    public static void main(String[] args) throws IOException
    URL u = new URL("http://forum.java.sun.com/index.jsp");
    URLConnection connection = u.openConnection();
    // check if response code is HTTP_OK (200)
    HttpURLConnection httpConnection = (HttpURLConnection)connection;
    int code = httpConnection.getResponseCode();
    if (code != HttpURLConnection.HTTP_OK)
    String message = httpConnection.getResponseMessage();
    System.out.println(code + " " + message);
    return;
    // read server response
    InputStream in = connection.getInputStream();
    BufferedReader reader = new BufferedReader(
    new InputStreamReader(in));
    boolean done = false;
    while (!done)
    String input = reader.readLine();
    if (input == null) done = true;
    else System.out.println(input);
    }

  • How to get jsp page form action this page use ajax

    i want to get form action result editThree div. however, ajaxpage open new window.how to decide it?
    ajaxCallPages.js
    var loadedobjects=""
    var loadingcontainer="loading"
    var loadstatustext="<img src='images/loading.gif' />" //loading
    var rootdomain="http://"+window.location.hostname
    function ajaxpage(url, containerid ){
    var page_request = false
    if (window.XMLHttpRequest) // if Mozilla, Safari etc
    page_request = new XMLHttpRequest()
    else if (window.ActiveXObject){ // if IE
    try {
    page_request = new ActiveXObject("Msxml2.XMLHTTP")
    catch (e){
    try{
    page_request = new ActiveXObject("Microsoft.XMLHTTP")
    catch (e){}
    else
    return false
    document.getElementById(containerid).innerHTML=loadstatustext // loading
    page_request.onreadystatechange=function(){
    loadpage(page_request, containerid)
    page_request.open('GET', url, true)
    page_request.send(null)
    function loadpage(page_request, containerid){
    if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
    document.getElementById(containerid).innerHTML=page_request.responseText
    userEditIformation.jsp
    <script language="JavaScript" src="function/ajaxCallPages.js"></script>...
    <div id="editTwo">
    <table width=100% cellpadding=0 cellspacing=0 border=0>
    <tr>
    <td>
    <form name="myform" action="pages/editUser.jsp" method="post">
    <table width=100% cellpadding=0 cellspacing=0 border=0>
    <tr>
    <td>
    <table width=100% cellpadding=3 cellspacing=1 border=0 bgcolor="#cccccc">
    <tr valign=top>
    <td bgcolor="#666666" width=150 style="color:#FFFFFF;" align="right">User group:</td>
    <td bgcolor="#f5f5f5"> <select name="UserGroup" id="lgroup">
    <option>Administrator</option>
    <option>Editor</option></select>
    </td>
    </tr>
    <tr valign=top>
    <td bgcolor="#666666" width=150 style="color:#FFFFFF;" align="right">User name:</td>
    <td bgcolor="#f5f5f5"><input type="text" id="lname" name="uname" maxlength="20" value=""> </td>
    </tr>
    <tr valign=top>
    <td bgcolor="#666666" width=150 style="color:#FFFFFF;" align="right">E-Mail:</td>
    <td bgcolor="#f5f5f5"><input type="text" id="lmail" name="uemail" value="" onkeypress="return checkEnter(event);" onKeyPress="Comment = false; Email = true; PostalCode = false; Go();" onChange="this.value = ignoreSpaces(this.value);"></td>
    </tr>
    <tr valign=top>
    <td bgcolor="#666666" width=150 style="color:#FFFFFF;" align="right">New password:</td>
    <td bgcolor="#f5f5f5"><input type="password" id="lpass1" name="upass1" maxlength="20" value="" onkeypress="return checkEnter(event);" onKeyPress="Comment = true; Email = false; PostalCode = false; Go();" onChange="this.value = ignoreSpaces(this.value);"></td>
    </tr>
    <tr valign=top>
    <td bgcolor="#666666" width=150 style="color:#FFFFFF;" align="right">Verify password:</td>
    <td bgcolor="#f5f5f5"><input type="password" id="lpass2" name="upass2" maxlength="20" value="" onkeypress="return checkEnter(event);" onKeyPress="Comment = true; Email = false; PostalCode = false; Go();" onChange="this.value = ignoreSpaces(this.value);"></td>
    </tr>
    <tr valign=top>
    <td bgcolor="#666666" width=150 style="color:#FFFFFF;" align="right">Phone:</td>
    <td bgcolor="#f5f5f5"><input type="text" id="lphone" name="uphone" value="" onkeypress="return checkIt(event);" onChange="this.value = ignoreSpaces(this.value);"></td>
    </tr>
    <tr valign=top>
    <td bgcolor="#666666" width=150 style="color:#FFFFFF;" align="right">Block:</td>
    <td bgcolor="#f5f5f5">
    <table cellpadding=0 cellspacing=0 border=0>
    <tr>
    <td><input type="radio" name="ustatus" id="lradio1" value="1"></td><td>Yes </td>
    <td><input type="radio" name="ustatus" id="lradio2" value="0" ></td><td>No </td>
    </tr>
    </table>
    </td>
    </tr>
    <tr valign=top>
    <td bgcolor="#666666" width=150 style="color:#FFFFFF;" align="right">Register date:</td>
    <td bgcolor="#f5f5f5"><%getDateTimeValue valueOne= new getDateTimeValue(); out.println(valueOne.getDateTime());</td>
    </tr>
    <tr valign=top>
    <td bgcolor="#666666" width=150 style="color:#FFFFFF;" align="right">Last visit date:</td>
    <td bgcolor="#f5f5f5"><%getDateTimeValue valueTwo= new getDateTimeValue(); out.println(valueTwo.getDateTime());</td>
    </tr>
    </table>
    </td>
    </tr>
    <tr><td> </td></tr>
    <tr><td><input type="button" onclick="ajaxpage('pages/editUser.jsp', 'editThree')" value="Send"/> </td></tr>
    <tr><td height=18 id="eoncmssend"></td></tr>
    </table>
    </form>
    </td>
    </tr>
    </table></div>
    <div id="editThree">
    </div>
    editUser.jsp
    <html>
    <head>
    <link rel="stylesheet" href="css/editUser.css" type="text/css"></link>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
    <%
    String ugroup=null;
    String phone=null;
    String name=null;
    if(request.getParameter("uname")!=null){
    name=request.getParameter("uname");
    if(request.getParameter("uphone")!=null)
    phone=request.getParameter("uphone");
    out.println(name);
    out.println(phone);
    %>
    </body>
    </html>
    ../

    From the HTTP spec (http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html):
    14.36 Referer
    The Referer[sic] request-header field allows the client to specify, for the server's benefit, the address (URI) of the resource from which the Request-URI was obtained (the "referrer", although the header field is misspelled.) The Referer request-header allows a server to generate lists of back-links to resources for interest, logging, optimized caching, etc. It also allows obsolete or mistyped links to be traced for maintenance. The Referer field MUST NOT be sent if the Request-URI was obtained from a source that does not have its own URI, such as input from the user keyboard.
    Referer = "Referer" ":" ( absoluteURI | relativeURI )
    Example:
    Referer: http://www.w3.org/hypertext/DataSources/Overview.html

  • How to get a HttpServletRequest instance from ApplicationModule ?

    All methods that I use as data actions are located in ApplModuleImpl.java. I need to get an IP address of an user using one of those methods. The problem is that I have to get an instance of HttpServletRequest (which have a getRemoteAddr() method) but I don't know how to do it from Application Module.
    Any ideas ?

    I approached a similar problem by extending the PageController and the ApplicationModule classes for the application (in the ViewController and Model projects respectively). Rather than tie the AppModule directly to the HTTP request object, I extended the PageController subclass to process the request object for specific information needed from it and communicate to the ApplicationModule as needed.
    In the extended PageController subclass, you'll have to import javax.servlet.http.HttpServletRequest and use
    HttpServletRequest request = (HttpServletRequest) context.getEnvironment().getRequest(); to get reference to the request object.
    I extended the ApplicationModule with setter methods to pass information into it from the specific PageController subclasses; the approach keeps the model layer more independent of the web-browser layer (it's not dependent on an HttpServletRequest object), and still allows the AppModule to be used with different UI technologies.
    We also needed to get the custom PageController methods invoked at the right points.
    Edited by: rpalazola on Sep 16, 2008 11:37 AM
    Edited by: rpalazola on Sep 16, 2008 11:44 AM

  • How to get application module instance from java bundle?

    Hi!
    I would like to build an application that would get all translations from a database table.
    So I created application module for translations that contains a view object which is selecting translations for specific language from a database table. I exposed a method in application module as client interface which returns HashMap<String, String> for all translations for specific language. When I test my view and client interface method call they work fine.
    Then I created java bundle classes to get translations for specific language. Then I tried to override public Object[][] getContents() method.
    I tried to get my translations application module like this:
    SharedTranslationsAppModuleImpl am = new SharedTranslationsAppModuleImpl();
    Map<String, String> translationsMap = am.getTranslations(this.getLocaleCode); // Client interface method call
    In getTranslations(String LocaleCode) I try to get that view (which would select translations from database) but it returns NULL and I get NPE error message.
    So what is the right way to get application module from java bundle file? Now everytime application wants to get translations, application stops and displays NPE message.
    Regards, Marko
    I use JDeveloper 11.1.2.1.0

    Marko,
    you can't just instantiate an application module. An application module has to be set up, db connections and memory pools have to be initialized and ....
    Can you describe why and when you try to read the resource bundle from the db and where the resource bundle is used?
    This blog may be what you are looking for http://technology.amis.nl/2012/08/10/implement-resource-bundles-for-adf-applications-in-a-database-table/
    Timo

  • Runtime error encounter when getting instance from ResourceFactory

    Hi,
       I'm developing a IView report on the documents' status in the repository, but i have encounter the following runtime error when I get an resource instance from the ResourceFactory,
    <i>Portal Runtime Error
    An Exception occurred while processing a request for:
    IView: N/A
    Component: N/A
    com/sapportals/wcm/repository/IResourceFactory</i>
    My codes are as follows:
    <i>IResourceFactory factory = Resourcefactory.getInstance()</i>
    I try to catch the ResourceException(), but an similar runtime error occured. I'm using PDK EP 6.0_60.2.2
    Thanks for any suggestions/solutions provided.

    Hi,
    did you set the SharingReference attribute in portalapp.xml to "knowledgemanagement, usermanagement" ?
    Best regards,
    Thilo

  • Render a JSP page into HTML in a String

    I am using a mail template system that gets templates as JSP pages placed in /WEB-INF/mailtemplates/
    I want to internally parse JSPs as if they were real JSPs in my tomcat but:
    - Get get them using getResourceAsStream (or any other way)
    - make JSP engine translate JSP into HTML into a String object.
    - Send a mail with this HTML. (this part is already finished)
    What I need is a method with the following proposed signature:
    public String getMailTemplate(java.io.InputStream jspPageStream, javax.servlet.HttpServletRequest request) {}
    The method must get the JSP from the stream, render it into the HTML and return it as a String.
    Of course, it must render the JSP as a real JSP, using the apserver JSP engine. It must so replace any tags and EL objects:
    ${session.user.name} -> The name of the user
    <c:forEach, ...
    etc. etc. etc.
    �Any ideas / directions on how to achieve this?
    thanks,
    Ignacio

    Ok, just tried it out myself, and I'm getting the same result you are.
    Nothing makes it out to the RedirectingServletResponse.
    It appears to be buffering it somewhere in the included page.
    If you put a command to flush the buffer on the jsp page being included: <% out.flush; %> then it works.
    So why doesn't it work normally? Why doesn't the call to requestDispatcher.include (or forward) flush/commit its response?
    I will admit to being stuck on this one. I'm figuring its something in the internal workings of Tomcat/JSP to do with when a page is flushed or not, but I can't thing of anything right now.
    Here is the test I put together to try this out (along with a few corrections to my previous code). I will admit to being stumped :-)
    The response wrapper:
    package web;
    import java.io.IOException;
    import java.io.OutputStream;
    import java.io.PrintWriter;
    import javax.servlet.ServletOutputStream;
    import javax.servlet.ServletResponse;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpServletResponseWrapper;
    public class RedirectingServletResponse extends HttpServletResponseWrapper {
        RedirectServletStream out;
         * @param arg0
        public RedirectingServletResponse(HttpServletResponse response, OutputStream out) {
            super(response);
            this.out = new RedirectServletStream(out);
        /* (non-Javadoc)
         * @see javax.servlet.ServletResponse#flushBuffer()
        public void flushBuffer() throws IOException {
             out.flush();       
        /* (non-Javadoc)
         * @see javax.servlet.ServletResponse#getOutputStream()
        public ServletOutputStream getOutputStream() throws IOException {
            return out;
        /* (non-Javadoc)
         * @see javax.servlet.ServletResponse#getWriter()
        public PrintWriter getWriter() throws IOException {
            return new PrintWriter(out);
        /* (non-Javadoc)
          * @see javax.servlet.ServletResponseWrapper#getResponse()
         public ServletResponse getResponse() {
              return super.getResponse();
         /* (non-Javadoc)
          * @see javax.servlet.ServletResponseWrapper#setResponse(javax.servlet.ServletResponse)
         public void setResponse(ServletResponse arg0) {
              super.setResponse(arg0);
         private static class RedirectServletStream extends ServletOutputStream {
            OutputStream out;
            RedirectServletStream(OutputStream out) {
                this.out = out;
            public void write(int param) throws java.io.IOException {
                out.write(param);
    A JSP using this class: requestWrapperTest.jsp
    <%@ page import="java.io.*" %>
    <%@ page import="web.RedirectingServletResponse" %>
    <%@ page contentType="text/html;charset=UTF8" %>
    <%!
    public String getEmailText(HttpServletRequest request, HttpServletResponse response, String emailURL) {
         try{
           // create an output stream - to file, to memory...
           ByteArrayOutputStream out = new ByteArrayOutputStream();
           // create the "dummy" response object
           RedirectingServletResponse dummyResponse;
           dummyResponse = new RedirectingServletResponse(response, out);
           // get a request dispatcher for the email template to load 
           RequestDispatcher rd = request.getRequestDispatcher(emailURL);
           // execute that JSP
           rd.include(request, dummyResponse);
           // at this point the ByteArrayOutputStream has had the response written into it.
           dummyResponse.flushBuffer();
           byte[] result = out.toByteArray();
           System.out.println("result = " + result.length);
           // now you can do with it what you will.
           String emailText = new String(result);
           return emailText;
         catch (Exception e){
              e.printStackTrace(System.out);
              return "DANGER WILL ROBINSON!";
    %>
    <html>
    <body>
    <h2> Server Info Virtual!!</h2>
    Server info = <%= application.getServerInfo() %> <br>
    Servlet engine version = <%=  application.getMajorVersion() %>.<%= application.getMinorVersion() %><br>
    Java version = <%= System.getProperty("java.vm.version") %><br>
    <hr>
    <%
      String result = getEmailText(request, response, "/testLoad.jsp");
      System.out.println(result);
    %>
    <%= result %>
    </body>
    </html>------------------------------------------------------------------
    And the template page being included: testLoad.jsp
    This is the page loaded for testing
    <%
       System.out.println("in the inner jsp");
       // uncomment the following line to see this example work
       //out.flush();
    %>

  • Publish Internal JSP Page as Portlet

    9ias 9.0.2.0.1
    Portal 9.0.2.0.3
    I have written some Internal JSP pages that I now want to display as a portlets within a normal portal page. However I am unable to locate a "Publish As Portlet" option in the properties of the JSP pages.
    Does anyone know if this is possible and if so, point me in the right direction?
    Thanks,
    Paul.

    Hiya (and bump, I do realize this post is ancient...).
    It seems to me that one simply cannot publish a jsp-page as a portlet. I have this exact issue as well, pl/sql implementation of what I'm trying to do (utilizing utl_http) is so buggy it will not work, jsp works beautifully with just a few lines of code, but what use is a jsp page when I cannot utilize it?
    What is the point of jsp-pages in Oracle portal?

  • Doubt in Getting and Adding ManagedBean from FacesContext???

    Hi all,
    I would like to know the proper way to get a managedBean instance from FacesContext.
    let us consider the ways i follow normally
    Way 1.
    Mbean mBean=  (Mbean )FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get(managedBean);
              if(mBean== null){
                        mBean = new Mbean();
                        FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put(managedBean,mBean );
         Way 2.
    Mbean  mBean = (Mbean)((ValueBinding) getValueBinding(getElExpr(beanName))).getValue(getFacesContext());Those two ways mentioned above are used to get the managed bean Mbean from context level,my query is which one out of
    these two ways is the best?
    what exactly getValueBinding(getElExpr(beanName))).getValue(getFacesContext()); line does?
    Thanks in advance,
    sundar.

    Way 1 will break if you change the scope of the bean in the faces-config.xml. Way 2 won't.
    Here are more ways: [http://balusc.blogspot.com/2006/06/communication-in-jsf.html#AccessingAnotherManagedBean].
    If you're using JSF 1.1, I would use the createValueBinding approach. If you're using JSF 1.2, I would use the evaluateExpressionGet approach. But I more prefer the approach of injecting the one bean as a managed property of the other bean: [http://balusc.blogspot.com/2006/06/communication-in-jsf.html#InjectingManagedBeansInEachOther].

  • Cannot access precompiled JSP

    My application contains several JSP working correctly, but after I choose to precompile my JSP files (putting the compiled classes in classpath). The server return a 404 indicating cannot find the JSP pages.
    It seems like the
    RequestDispatcher dispatcher=request.getRequestDispatcher("xxx.jsp");
    can no longer find the JSP page anymore. What should I put there instead? Moreover, I will still use JSP for faster development and debugging purposes, can I write it so that the same code runs for both raw JSP pages and precompiled JSP?
    Any suggestion will be appreciated!

    Thanks for your info on the creation of web.xml fragment, it really helps. I am using Ant to precompile the JSP to deploy on Jetty.
    But, the webxml and webinc attribute just does not output any file as specified. However, when I tried it with the task like this:
    <java classname="org.apache.jasper.JspC" fork="true" failonerror="true">
    <arg line="-l -d ${web}/WEB-INF/work -webinc ${web}/jspc.xml -webapp ${web}"/>
    it seems to create the webinc, however, the JSPC just doesn't work as it says
    org.xml.sax.SAXException: Internal Error: File /javax/servlet/resources/web-app_2_3.dtd not found
    Now both ways seems unworkable, do you or anyone have any idea?

  • How to get the view tree from a jsp page

    Hi,
    I would like to get the view tree of a jsp page. The idea is to dynamically include the content of one or more jsf pages into a UIPanel during a "value changed" event.
    So, i could get from an arbitrary page like ...
    <%@ taglib uri="http://java.sun.com/jsf/core"   prefix="f" %>
    <%@ taglib uri="http://java.sun.com/jsf/html"   prefix="h" %>
    <h:panelGrid columns="3" width="100%" rowClasses="gridTop">
        <h:outputText value="#{someBean.someValue}"/>
    </h:panelGrid>... the corresponding List of components...
    Any idea?

    Thanks for your answer Jayashri,
    The view tree can be retrieved by this way during the page is parsed, for example with scriptlets <%%>, or once the page has been parsed (the view has been builded and attached to the FacesContext).
    My problem is to get the view tree of a page from another Context.
    The idea is to build a dynamic layout of some pages that represents "views". I can imagine this like the concept of perspectives and views of Eclipse IDE.
    Because of the difficulty to build it with pure JSP (cannot use dynamic ID nor JSTL ForEach), I try to build it into my backing bean and to bind it with a <h:panelGrid/>. By this way, I'm not able to use the <jsp:include/> tag as I usually did to include some content into the view tree.
    Sorry for my english ;)
    - Renaud.

  • How to get multiple selections from jsp page in my servlet

    Hello Everyone,
    I've a list that allows users to make multiple selections.
    <select name=location multiple="multiple">
        <option>
             All
        </option>
        <option>
             Hyd
        </option>
        <option>
             Dub
        </option>
        <option>
             Mtv
        </option>
      </select>I want to get the selections made by user in jsp page from my servlet, selections can be multiple too.
    ArrayList locList = new ArrayList();
    locList = request.getParameter("location");when I do so, I get compilation error as the request returns string type. How do I then get multiple selections made by the user.
    Please let me know.

    For those kind of basic questions it would help a lot if you just gently consult the javadocs and tutorials.
    HttpServletRequest API: [http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpServletRequest.html]
    Java EE tutorial part II: [http://java.sun.com/javaee/5/docs/tutorial/doc/]
    Coreservlet tutorials: [http://courses.coreservlets.com/Course-Materials/]

  • How to get the value from a database without submitting a jsp page

    I have a jsp which has a text box depending on the value entered I want to get the value from a database for other two fields with out submitting jsp page. I am using struts.
    Thanks For any assistance provided.

    Alright,here is an example for you for the first case.
    Present.jsp:
    ============
    <html:html>
    <head>
    <title><html:message key="page.title"/></title>
    </head>
    <body>
    <html:form action="ChangeEvent.do">
    <html:hidden property="method"/>
    <!-- Submitting the Form onKeyUp of EmpId field and trying to save the
         state of the Form in the scope of session -->
    Emp Id:<html:text property="empId" size="5"  onkeyup="if(true){this.form.elements[0].value='populateDetails';this.form.submit();}"/>
    Emp Name:<html:text property="empName" size="10" />
    Email Address:<html:text property="email" size="10" />
    <html:submit>Submit</html:submit>
    </html:form>
    </body>
    </html:html>struts-config.xml:
    ==================
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
    <struts-config>
    <!-- Form bean which stores the properties of all the Form elements -->
    <form-beans>
    <form-bean name="employeeFormBean" type="org.apache.struts.action.DynaActionForm">
       <form-property name="empId" type="java.lang.String"/>
       <form-property name="empName" type="java.lang.String"/>
       <form-property name="email" type="java.lang.String" />   
    </form-bean>
    </form-bean>
    <action-mappings>
    <action path="/ChangeEvent" type="Test.GetChangeAction" name="employeeFormBean" scope="request" parameter="method"> 
    <!-- On successful call of DB the Page has to be forwarded to the same page again by
          uploading updated form bean values. -->
    <forward name="success" path="/Present.jsp"></forward>
    <forward name="failed" path="/error.jsp"></forward>
    </action>
    </action-mappings>
    </struts-config>GetChangeAction.java:
    =====================
    public class GetChangeAction extends DispatchAction{
      public ActionForward populateDetails(ActionMapping mapping,ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
            DynaActionForm dForm = (DynaActionForm)form;
            String empId = dForm.get("empId");     
            // calling Model / Db and then getting back Employee Details
            EmployeeBean eb = ModelUtils.getDetails(empId);
            // Updating form bean by updating values from the Model 
            dForm.set("empName".eb.getEmpName()); 
            dForm.set("email".eb.getEmail());
            return mapping.findForward("success");
    }well to me this should work regardless to any browser but we need to make sure we put in our logic properly.

  • Help needed urgently to get the values from the jsp page.

    hi,
    I am badly stuck into this problem.Please help me and find a solution.
    I am using ms-access and jsp.
    my database structure is as given below:
    m_emp_no | from_date | to_date | approver| status |
    1002 | 22/9/2008 | 23/9/2008|1003 |pending
    1004 | 29/9/2008 | 30/9/2008|1003 |pending
    2044 | 15/9/2008 | 16/9/2008|3076 |pending
    now this is exactly a leave apply scenario where a page is displayed and the user has to fill in the details to apply leave.then the approver has to approve that leaves so even, he should get the details in his account.
    for example here 1003 has to approve leaves for 1002 & 1004.i am able to fetch data from database for the particular approver here is the coding:
    <html>
    <body>
    <h2 align="center"><u><b><span style="background-color: #FFFFFF"><font color="#C0C0C0" face="Comic Sans MS">Leave
    Approval Requests</font></span></b></u></h2>
    <form method="POST" name="f1" action="update.jsp">
    <%
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:employee_details");
    PreparedStatement p=null;
    p=con.prepareStatement("select * from emp_leave_application where approver='"+username+"'");
    ResultSet r=p.executeQuery();
    while(r.next())
    %>  <table border="1" width="100%" bordercolor="#FFFFFF" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF">
        <tr>
          <td width="100%" bgcolor="#999966"><b><u><%=r.getString(2)%></u></b></td>
        </tr>
      </table>
      <table border="1" width="100%" height="171" bordercolor="#FFFFFF" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF">
        <tr>
          <td width="100%" height="165" valign="top">
            <p align="left"><b>User ID</b>        :
    <input type="text" name="id" value="<%=r.getString(1)%>"  size="4   
         <b>status</b>:<%=r.getString(5)%</p>
    <p><b>Leave From</b> : <%=r.getString(2)%></p>
    <p><b>Leave From</b> : <%=r.getString(3)%></p>
    <p><b>Approve</b> : <select  size="1" name="approved">
            <option value="Approved">Approved</option>
            <option value="Cancelled">Cancelled</option>        </select></p>
    <%
    con.close();
    %>
      <table border="1" width="100%" bordercolor="#FFFFFF" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF">
              <tr>
                <td width="100%" bgcolor="#999966">
                  <p align="center"><input type="reset" value="Clear" name="B1"> 
                  <input type="submit" value="Submit" name="B2"></td>
              </tr>
            </table>
            </td>
        </tr>
      </table>
    </form>
    </body>
    </html>{code}
    this will display both the rows but when i try to retrieve the values into update.jsp using the code given below it gives me only one value which is the first 1002.
    {code}approved=(String)request.getParameter("approved");
    id=(String)request.getParameter("id");{code}
    but i need both the values to be inserted into the update.jsp only then the approver will be able to approve the leaves individually with respect to the m_emp_no.
    please help me out.
    thanks in advance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    My comments below are all between (((((( and ))))))
    <html>
    <body>
    <h2 align="center"><u><b><span style="background-color: #FFFFFF"><font color="#C0C0C0" face="Comic Sans MS">Leave
    Approval Requests</font></span></b></u></h2>
    <form method="POST" name="f1" action="update.jsp">
    <%
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:employee_details");
    PreparedStatement p=null;
    p=con.prepareStatement("select * from emp_leave_application where approver='"+username+"'");
    ResultSet r=p.executeQuery();
    while(r.next())
    %> <table border="1" width="100%" bordercolor="#FFFFFF" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF">
    <tr>
    <td width="100%" bgcolor="#999966"><b><u><%=r.getString(2)%></u></b></td>
    </tr>
    </table>
    <table border="1" width="100%" height="171" bordercolor="#FFFFFF" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF">
    <tr>
    <td width="100%" height="165" valign="top">
    <p align="left"><b>User ID</b> :
    <input type="text" name="id" value="<%=r.getString(1)%>" size="4   
    ((((((( in the statement above, name="id" should be changed to something like name="id"<%=ii%>
    Where ii is a counter that tells you how many times you have gone through the loop so far.
    The reason for this is that each textfield you generate must have a unique name rather than all have the same name
    such as 'id'. This change will give them names such as id0, id1, id2. Then when you submit the page, you can uniquely
    identify each input textfield.))))))
    <b>status</b>:<%=r.getString(5)%</p>
    <p><b>Leave From</b> : <%=r.getString(2)%></p>
    <p><b>Leave From</b> : <%=r.getString(3)%></p>
    <p><b>Approve</b> : <select size="1" name="approved">
    (((( the above select also has to have a unique name for each time through the loop. Change it to name="approved"<%=ii%>
    <option value="Approved">Approved</option>
    <option value="Cancelled">Cancelled</option> </select></p>
    <%
    con.close();
    %>
    <table border="1" width="100%" bordercolor="#FFFFFF" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF">
    <tr>
    <td width="100%" bgcolor="#999966">
    <p align="center"><input type="reset" value="Clear" name="B1">
    <input type="submit" value="Submit" name="B2"></td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    </form>
    </body>
    </html>
    (((((((note you would be better off long term to put your business logic in a servlet and dispatch to the JSP page which will only have the responsiblity to display the data.
    Also, connection pooling is better than the above.

  • Unable get complete filepath from jsp page using request.getParameter()

    Hey all,
    i am actually trying to get the selected file path value using request.getParameter into the servlet where i will read the (csv or txt) file but i dont get the full path but only the file name(test.txt) not the complete path(C:\\Temp\\test.txt) i selected in JSP page using browse file.
    Output :
    FILE NAME : TEST
    FILE PATH : test.txt
    Error : java.io.FileNotFoundException: test.txt (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:106)
    at java.io.FileReader.<init>(FileReader.java:55)
    at com.test.TestServlet.processRequest(TestServlet.java:39)
    at com.test.TestServlet.doPost(TestServlet.java:75)
    JSP CODE:
    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>DEMO SERVLET</title>
    </script>
    </head>
    <body>
    <h2>Hello World!</h2>
    <form name="myform" action="TestServlet" method="POST"
    FILE NAME : <input type="text" name="filename" value="" size="25" /><br><br>
    FILE SELECT : <input type="file" name="myfile" value="" width="25" /><br><br>
    <input type="submit" value="Submit" name="submit" />
    </form>
    </body>
    </html>
    Servlet Code :
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException, FileNotFoundException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    try {
    String filename = request.getParameter("filename");
    out.println(filename);
    String filepath = request.getParameter("myfile");
    out.println(filepath);
    out.println("<html>");
    out.println("<head>");
    out.println("<title>Servlet TestServlet</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<h1>Servlet TestServlet at " + request.getContextPath() + "</h1>");
    if (filepath != null) {
    File f = new File(filepath);
    BufferedReader br = new BufferedReader(new FileReader(f));
    String strLine;
    String[] tokens;
    while ((strLine = br.readLine()) != null) {
    tokens = strLine.split(",");
    for (int i = 0; i < tokens.length; i++) {
    out.println("<h1>Servlet TestServlet at " + tokens[i] + "</h1>");
    out.println("----------------");
    out.println("</body>");
    out.println("</html>");
    } finally {
    out.close();
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    Needed Output :
    FILE NAME : TEST
    FILE PATH : C:\\Temp\\test.txt
    Any suggestions Plz??

    As the [HTML specification|http://www.w3.org/TR/html401/interact/forms.html] states, you should be setting the enctype to multipart/form-data to be able to upload files to the server. In the server side, you need to process the multipart/form-data binary stream by parsing the HttpServletRequest#getInputStream(). It is a lot of work to get it to work flawlessly. There are 3rd party API's around which can do that for you, such as [Apache Commons FileUpload|http://commons.apache.org/fileupload] (carefully read the User Guide how to use it).
    You can also consider to use a Filter which makes use of the FileUpload API to preprocess the request so that you can continue writing the servlet code as usual. Here is an example: [http://balusc.blogspot.com/2007/11/multipartfilter.html].

Maybe you are looking for

  • Error message display for radiobuttongroup using report_attribute_error_msg

    Hi, We are displaying error message on the submit button of a form. We have different UI elements in the form which are mandatory to enter by the user. So we are using 'CALL METHOD lo_message_manager->report_attribute_error_message' method to display

  • Error while saving purchase order

    Hi all, While saving purchase order i am getting the following error. Syntax error in program SAPLV61A in include RV64A932 in line 10 Statement"*&"is not defined.check your spelling. Thanks& Regards, Hari.

  • Broken link on copy and paste from normal user to required upper privilege user

    Hi,  I've encountered an error that is probably coming from environment variables. When I copy %document%\something\ from a normal user to %programs% where it require administrator privilege, i'm prompted with a credential window ( so far so good ) u

  • Acrobat 8 crashes when extracting pages

    Currently experiencing problems when trying to extract pages from PDFs in Acrobat 8 running on Mac 10.5.5. Extracts the pages but before you are able to save the wheel of death starts to spin and Acrobat freezes. Inserts, deletes etc., and saves with

  • EA6500 Connectivity issues

         I have had this router for about 6 months. The first 3 months were problem free as far as the internet connection goes. It seems like after the latest firmware update I've started having these problems. I don't know if that is a factor or not. I