Re: Including text files in jsp from another web application - Weblogic

This is a discussion on Re: Including text files in jsp from another web application - Weblogic ; Because HTML is XML incorrectly JSP tags often don't cause errors. In this case, has a 'page' attribute and not a 'file' attribute. However, that still isn't going to help because will only include from the same web application. To ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Re: Including text files in jsp from another web application

  1. Re: Including text files in jsp from another web application

    Because HTML is XML incorrectly JSP tags often don't cause errors. In this
    case, has a 'page' attribute and not a 'file' attribute. However,
    that still isn't going to help because will only include from the
    same web application.

    To include from another web application you are going to have to use
    ServletContext.getContext() and then use RequestDispatcher API.

    http://java.sun.com/j2ee/sdk_1.3/tec...va.lang.String)

    Sam

    jspguy wrote:

    > Hi Guys,
    >
    > I am trying to include a text file as part of a html page using JSP. JSP trying
    > to include the text file is in a war file and the text file from other web app.
    > directory. Server is weblogic server.
    > This line is in my jsp code:
    >
    > <% out.print("this is the test page with text file"); %>
    >
    >
    > but there is no output except the "this is the test page with text file" in browser.
    > In the server no error/exception.
    >
    > when I looked in the source of the generated html file I found this:
    >
    >
    >
    >
    >
    > this is the test page with text file
    >
    >
    >
    >
    >
    >
    > I tried with complete URL also..
    > Thanks.



  2. Re: Including text files in jsp from another web application


    Hi Sam,
    Thanks for the reply it really worked. I used this .. Please let me know whether
    it is correct.

    // WebApp is a web application.
    ServletContext sc= application.getContext("http://xxx.xx.xx.xxx:9001/WebApp/textfiles/test.txt")
    ;

    RequestDispatcher rd = sc.getRequestDispatcher("/textfiles/test.txt");

    rd.include(request, response);

    Thanks.



    Sam Pullara wrote:
    >Because HTML is XML incorrectly JSP tags often don't cause errors. In
    >this
    >case, has a 'page' attribute and not a 'file' attribute.
    > However,
    >that still isn't going to help because will only include
    >from the
    >same web application.
    >
    >To include from another web application you are going to have to use
    >
    >ServletContext.getContext() and then use RequestDispatcher API.
    >
    >http://java.sun.com/j2ee/sdk_1.3/tec...va.lang.String)
    >
    >Sam
    >
    >jspguy wrote:
    >
    >> Hi Guys,
    >>
    >> I am trying to include a text file as part of a html page using JSP.

    >JSP trying
    >> to include the text file is in a war file and the text file from other

    > web app.
    >> directory. Server is weblogic server.
    >> This line is in my jsp code:
    >>
    >> <% out.print("this is the test page with text file"); %>
    >>
    >>
    >> but there is no output except the "this is the test page with text

    >file" in browser.
    >> In the server no error/exception.
    >>
    >> when I looked in the source of the generated html file I found this:
    >>
    >>
    >>
    >>
    >>
    >> this is the test page with text file
    >>
    >>
    >>
    >>
    >>
    >>
    >> I tried with complete URL also..
    >> Thanks.

    >



  3. Re: Including text files in jsp from another web application

    I think it is cleaner like this (I'm a bit surprised that long url worked):

    // WebApp is a web application.
    ServletContext sc= application.getContext("/WebApp");

    RequestDispatcher rd = sc.getRequestDispatcher("/textfiles/test.txt");

    Sam

    jspguy wrote:

    > Hi Sam,
    > Thanks for the reply it really worked. I used this .. Please let me know whether
    > it is correct.
    >
    > // WebApp is a web application.
    > ServletContext sc= application.getContext("http://xxx.xx.xx.xxx:9001/WebApp/textfiles/test.txt")
    > ;
    >
    > RequestDispatcher rd = sc.getRequestDispatcher("/textfiles/test.txt");
    >
    > rd.include(request, response);
    >
    > Thanks.
    >
    >
    >
    > Sam Pullara wrote:
    >
    >>Because HTML is XML incorrectly JSP tags often don't cause errors. In
    >>this
    >>case, has a 'page' attribute and not a 'file' attribute.
    >>However,
    >>that still isn't going to help because will only include

    >
    >>from the

    >
    >>same web application.
    >>
    >>To include from another web application you are going to have to use
    >>
    >>ServletContext.getContext() and then use RequestDispatcher API.
    >>
    >>http://java.sun.com/j2ee/sdk_1.3/tec...va.lang.String)
    >>
    >>Sam
    >>
    >>jspguy wrote:
    >>
    >>
    >>>Hi Guys,
    >>>
    >>>I am trying to include a text file as part of a html page using JSP.

    >>
    >>JSP trying
    >>
    >>>to include the text file is in a war file and the text file from other

    >>
    >>web app.
    >>
    >>>directory. Server is weblogic server.
    >>>This line is in my jsp code:
    >>>
    >>><% out.print("this is the test page with text file"); %>
    >>>
    >>>
    >>>but there is no output except the "this is the test page with text

    >>
    >>file" in browser.
    >>
    >>>In the server no error/exception.
    >>>
    >>>when I looked in the source of the generated html file I found this:
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>this is the test page with text file
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>I tried with complete URL also..
    >>>Thanks.

    >>

    >



  4. Re: Including text files in jsp from another web application


    Thanks Sam,

    It's a charm!

    Sam Pullara wrote:
    >I think it is cleaner like this (I'm a bit surprised that long url worked):
    >
    >// WebApp is a web application.
    >ServletContext sc= application.getContext("/WebApp");
    >
    >RequestDispatcher rd = sc.getRequestDispatcher("/textfiles/test.txt");
    >
    >Sam
    >
    >jspguy wrote:
    >
    >> Hi Sam,
    >> Thanks for the reply it really worked. I used this .. Please let me

    >know whether
    >> it is correct.
    >>
    >> // WebApp is a web application.
    >> ServletContext sc= application.getContext("http://xxx.xx.xx.xxx:9001/WebApp/textfiles/test.txt")
    >> ;
    >>
    >> RequestDispatcher rd = sc.getRequestDispatcher("/textfiles/test.txt");
    >>
    >> rd.include(request, response);
    >>
    >> Thanks.
    >>
    >>
    >>
    >> Sam Pullara wrote:
    >>
    >>>Because HTML is XML incorrectly JSP tags often don't cause errors.

    > In
    >>>this
    >>>case, has a 'page' attribute and not a 'file' attribute.
    >>>However,
    >>>that still isn't going to help because will only include

    >>
    >>>from the

    >>
    >>>same web application.
    >>>
    >>>To include from another web application you are going to have to use
    >>>
    >>>ServletContext.getContext() and then use RequestDispatcher API.
    >>>
    >>>http://java.sun.com/j2ee/sdk_1.3/tec...va.lang.String)
    >>>
    >>>Sam
    >>>
    >>>jspguy wrote:
    >>>
    >>>
    >>>>Hi Guys,
    >>>>
    >>>>I am trying to include a text file as part of a html page using JSP.
    >>>
    >>>JSP trying
    >>>
    >>>>to include the text file is in a war file and the text file from

    >other
    >>>
    >>>web app.
    >>>
    >>>>directory. Server is weblogic server.
    >>>>This line is in my jsp code:
    >>>>
    >>>><% out.print("this is the test page with text file"); %>
    >>>>
    >>>>
    >>>>but there is no output except the "this is the test page with text
    >>>
    >>>file" in browser.
    >>>
    >>>>In the server no error/exception.
    >>>>
    >>>>when I looked in the source of the generated html file I found this:
    >>>>
    >>>>
    >>>>
    >>>>
    >>>>
    >>>>this is the test page with text file
    >>>>
    >>>>
    >>>>
    >>>>
    >>>>
    >>>>
    >>>>I tried with complete URL also..
    >>>>Thanks.
    >>>

    >>

    >



+ Reply to Thread