Trouble forwarding request from a servlet to a JSP in OAS 4.0.8.1 on NT

The OJSP release notes state that:
"Servlets and JSP cannot coexist as the same application" and "Requests cannot be passed between two separate applications."
Does this mean that my attempts to use the
the servlet RequestDispatcher to forward a request to a JSP are futile? If so, is this a problem that will be fixed in the future? I would like to use this feature!
This is the code (based on a sample from Sun's JSWDK 1.0.1) that doesn't work:
servletToJsp.java
import javax.servlet.*;
import javax.servlet.http.*;
public class servletToJsp extends HttpServlet {
public void doGet (HttpServletRequest request,
HttpServletResponse response) {
try {
getServletConfig().getServletContext().getRequestDispatcher("/jsp/jsptoserv/hello.jsp").forward(request, response);
} catch (Exception ex) {
ex.printStackTrace ();
I am able to use the <jsp:forward page="/servlets/servletToJsp" /> directive to go from a JSP page to a servlet (across two OAS Applications) and I also can forward a request via the dispatcher from one servlet to another in the same OAS application.
Any help in this area would be appreciated. Thanks.

I'm using OAS 4.0.8.1
You mean servlet to JSP does not work and JSP to servlet works for you????Yes - but I've only tried very simply examples.
That's different from my understanding. If you are using OAS 4081, both cases should not work.
The problem you mentioned will be fixed in future release of OAS.That's good to know - thanks!
null

Similar Messages

  • Challenge forwarding from a servlet to a JSP

    Redirecting information from a servlet to a JSP
    Hello Everyone,
         I am processing the contents of a html form using a servlet. After processing the
    information received and storing it into a javabean I am trying to pass control onto a jsp for
    display. At this stage the jsp does not display as desired due to a URL challenge. The URL
    which references my jsp is:
    http://localhot/ferngully/prefset.jspThis url has been designated to the jsp page 'prefset.jsp' by the application specific web.xml
    file (...I am using Tomcat 5!), the relevant contents of which follow:
    <servlet>
         <servlet-name>PreferenceSet</servlet-name>
         <jsp-file>/prefset.jsp</jsp-file>
    </servlet>
    <servlet-mapping>
         <servlet-name>PreferenceSet</servlet-name>
         <url-pattern>/ferngully/prefset.jsp</url-pattern>
    </servlet-mapping>If I access the page with the afore mentioned URL it displays correctly. However the URL which
    is returned to the browser after the servlet has forwarded control to the JSP is:
    http://localhost/ferngully/ferngully/PreferencesThe following form markup is used to access the servlet:
    <form name="form1" method="post" action="ferngully/Preferences"> I know that I have mapped the servlet correctly because the servlet performs it's programatic tasks happily :)
    I am using code within the servlet to forward control to the JSP, and I believe that this is the crux of my challenge.
    The code for the servlet is listed below.
    package userpreferences;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    public class PreferencesServlet extends HttpServlet
         public void init(ServletConfig config) throws ServletException
              super.init(config);
         public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
              doPost(request, response);
         public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
              String url = "/prefset.jsp";
              ServletContext servCont = getServletContext();
              RequestDispatcher reqDispatch = servCont.getRequestDispatcher(url);
              reqDispatch.forward(request, response);
    }I believe that the above highlighted code section is responsible for my challenge. I have tried changing the String url to "/ferngully/prefset.jsp",
    however there was no improvement in functionality.
    Can somebody please explain to me how I can go about directing the control of this process from the servlet to the jsp correctly? Particularly
    how I can go about making the url returned to the client correct for accessing the jsp page? Do I need to delete the mapping entry for the
    jsp page in web.xml? I am new to servlets & jsp so any help will be much appreciated.
    Thanks
    Kind Regards
    Davo

    3. >The following form markup is used to access the servlet:
    <form name="form1" method="post" action="ferngully/Preferences">Question 1:
         why do you specify your contextname in action attribute again ?
         General funda about urls:
         When you have an index.html loaded through http://localhost/index.html, then a link in that html whose url is,
         1. say, preferences.html (no forward slashes preffixed or suffixed) would load the html from the same folder.
         2. say, /ferngully/prefences.html, would attempt to load a html from the ferngully folder that is a sub-directory
    of your web-application
         3. say, /ferngully/prefences.jsp, would attempt to load a html from the ferngully folder that is a sub-directory
    of your web-application
         When you have a servlet whose url-pattern is set to intercept requests, it would intercept requests that have that
    pattern it is defined to intercept in web.xml (for example all the above requests in 1,2 and 3 would be intercepted
    by a servlet whose pattern is ferngully/*)
         Now if your action is not a specific resource (.jsp or .html), something like /preferences, this would map to a url
    /ferngully/preferences. (for which a resource should be defined in web.xml - either a servlet or a jsp)
    However the URL which is returned to the browser after the servlet has forwarded control to the JSP is:
    http://localhost/ferngully/ferngully/PreferencesTell us the url of the original html
    I know that I have mapped the servlet correctly because the servlet performs it's programatic tasks happily :)Tell us the url-appetrn of the servlet that intercepted your request
    Particularly
    how I can go about making the url returned to the client correct for accessing the jsp page?The url in the browser is always the request url, you cannot change it to the url of the jsp even which rendered the page
    through a fwd from the servlet.
    Do I need to delete the mapping entry for the
    jsp page in web.xml?Not necessary. You can access the jsp directly from the servlet while forwarding by
    1. specifying the exact path to the jsp. For example if the jsp is under a folder called jsps, your request dispatcher
    url ought to be /jsps/prefset.jsp
    2. specifying the jsp's url-pattern as specified in web.xml
    Questions Contd
    2. Why does the url pattern have to have a .jsp suffixed.
    From your code
    <url-pattern>/ferngully/prefset.jsp</url-pattern>It could equally well have been
    <url-pattern>/ferngully/prefset</url-pattern>And then your servlet would have to forward it to ("/ferngully/prefset")
    2. Your jsp-file mapping is in this form
    <jsp-file>/prefset.jsp</jsp-file>This assumes that the jsp is in the top-level folder of your web-application and not under
    any sub-directories. Correct ?
    cheers,
    ram.

  • Send some atributes from a Servlet to a JSP program

    Hi all,
              I am quite new to JSP programming and am facing a problem. I have a
              Servlet code which is supposed to send some attributes to a JSP, which
              will display the attribute that has been passed through the Servlet.
              the Servlet code to do so is,
              request.setAttribute("emailtxt","emailNewTxt");
              RequestDispatcher rd=request.getRequestDispatche("/emailChangeSuc.jsp");
              rd.forward(request,response);
              on the JSP side, I am reciving this attribute in the following way,
              <body>
              <%@content_type="text/html"%>
              <%! String emailTxt=HttpSession.getAttribute("emailNewTxt");%>
              and am displaying the value in this way
              <b><%=emailTxt%>
              but I am getting an error
              "non-static method getAttribute(java.lang.String) cannot be referenced
              from a static context
              probably occurred due to an error in /emailChangeSuc.jsp line 9:
              <%! String emailTxt=HttpSession.getAttribute("emailNewTxt");%>"
              Please help me solve this problem.
              Thanks in anticipation,
              Rajiv.
              

    "Rajiv" == Rajiv <[email protected]> writes:
                        Rajiv> Hi all,
              Rajiv> I am quite new to JSP programming and am facing a problem. I have a
              Rajiv> Servlet code which is supposed to send some attributes to a JSP, which
              Rajiv> will display the attribute that has been passed through the Servlet.
              Rajiv> the Servlet code to do so is,
              Rajiv> {
              Rajiv> request.setAttribute("emailtxt","emailNewTxt");
              Rajiv> RequestDispatcher rd=request.getRequestDispatche("/emailChangeSuc.jsp");
              Rajiv> rd.forward(request,response);
              Rajiv> }
              Rajiv> on the JSP side, I am reciving this attribute in the following way,
              Rajiv> <body>
              Rajiv> <%@content_type="text/html"%>
              Rajiv> <%! String emailTxt=HttpSession.getAttribute("emailNewTxt");%>
              Rajiv> and am displaying the value in this way
              Rajiv> <b><%=emailTxt%>
              Rajiv> but I am getting an error
              Rajiv> "non-static method getAttribute(java.lang.String) cannot be referenced
              Rajiv> from a static context
              Rajiv> probably occurred due to an error in /emailChangeSuc.jsp line 9:
              Rajiv> <%! String emailTxt=HttpSession.getAttribute("emailNewTxt");%>"
              First of all, you put the attribute into the request, but you're trying to read
              it from the session. Change it to "request.getAttribute(...".
              Second, your compile error is stating that the "getAttribute()" method of
              HttpSession is not a static method. If you really needed to reference the
              session, it would just be "session". Changing to "request" as in the first
              point, will avoid this problem.
              Third, remove the "!" from the scriptlet which declares and sets the "emailTxt"
              variable. That makes it declare an instance variable instead of a local
              variable. That will cause numerous problems with this.
              ===================================================================
              David M. Karr ; Java/J2EE/XML/Unix/C++
              [email protected] ; SCJP; SCWCD
              

  • How to display outsream from a servlet in a JSP

    I wrote a jsp file to call a Servlet, then want to display the result from the servlet in another jsp file. Anyone can give me possible solution or an example to illustrate it.
    Many thanks in advance.
    the file that call servlet in a jsp is as follow
    <form method="POST" action="myservlet">
    <table>
    <tr>
    <th align="center" colspan="2">
    Enter The query words
    </th>
    </tr>
    <tr>
    <th align="right">query words:</th>
    <td align="left">
    <input type="text" name="querywords" size="60">
    </td>
    </tr>
    <tr>
    <td align="right">
    <input type="submit" value="Search">
    </td>
    <td align="left">
    <input type="reset" value="Reset">
    </td>
    </tr>
    </table>
    </form>
    ............

    I would suggest that you use the Servlet to retrieve the data you are after and store it in the session. Then forward the user onto the JSP page where it can retrieve the object from the session and present it to the user in a formatted view.

  • How do I Display a string from a servlet into a JSP Page???? NEED HELP!!!!

    Hi guys,
    How do I Display a string from a servlet into a JSP Page...
    Ive tried so many bloody things!.....
    Simply.
    I get text from JSP. The servlet does what ever it does to the string.
    Now. Ive create sessions and bean things,.... how the hell do I display it in a text box... I can display on the screen.. but not in the text box.!!!
    please help!!!

    hmmm, I dont really like using JSP programming, u should be using JAVA..
    the way to do it is:
    Call and cast to the bean like this:
    <%@ page import="beans.*" %>
    <% //cast to bean get request create object
    userNameBean u= (userNameBean) request.getSession().getAttribute("userNameBean");
    then... all you do is call it like this:
    <input type="text" name="firstName" value="<%= u != null? u.getFirstName(): "" %>">
    this is the real programmers way,,,
    chet.~

  • Forwarding request from JSP/Servlet to EJB

    Is it possible to forward the HttpRequest,HttpResponse objects from a Servlet/JSP to an Entity/Session bean ?
    ie To forward the call using RequestDispatcher/forward to a Session bean which in turn calls the entiy bean for updating DB
    Ramesh

    I don't think that's possible and even if it is there's an easier way. Normally you just create an instance of the session bean in a servlet and pass it the information. The session bean then calls the entity bean which updates the database. You don't have to forward the request - just pass the data to the bean.

  • Send Get request from a servlet.

    Is it possible to send parameters from one servlet to another by using get? I don't want to use Post because the servlet recieving the parameters already has the post method doing something else. Any ideas?

    May you can use the RequestDispatcher for your use.
    Doc:
    public interface RequestDispatcher
    Defines an object that receives requests from the
    client and sends them to any resource (such as a servlet, HTML file, or JSP file) on the server.
    The servlet container creates the RequestDispatcher
    object, which is used as a wrapper around a server
    resource located at a particular path or given by a
    particular name.
    This interface is intended to wrap servlets, but a
    servlet container can create RequestDispatcher objects
    to wrap any type of resource.
    It send the requset with the same methode to an other resource. You don't have care about the parameter.
    Your code could look like this:
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException
            RequestDispatcher dispatcher = getServletConfig().getServletContext().getRequestDispatcher("/next");
            dispatcher.forward(request, response);
        }Dietmar

  • Webdispatcher to forward requests from internet to intranet?

    We need to direct requests from internet to our content server which is in the intranet (so that the content server images can be seen from the internet).
    We have a WAS WebDispatcher in the DMZ. Can we use this WD to provide the connectivity?
    For example:
    Our content server intranet URL is:
    http://contenterv.com:1090/path/image.jpg
    Our WebDispatcher URL is:
    http://webdisp.com/app_name
    http://webdisp.com/app_name  should resolve to http://contenterv.com:1090/path/image.jpg
    We tried WD http forwarding but it just forwards the request, does not resolve the name transparently. So the forwarding works but since http://contenterv.com:1090/path/image.jpg is not known in the internet, it fails.
    Thanks

    >
    Ghochi Elin Kuswoyo wrote:
    > hi guys,
    >
    > you need to add parameter in your sapwebdisp.pfl (sap webdispatcher profile) :
    >
    > icm/HTTP/redirect_0 = PREFIX=/,TO=/path_image
    >
    > thanks
    No, this wont work, becuase you need reverse-proxy function rather than URL redirection, because internet user wont be access the intranet server even you give them the URL.
    I cannot get you the detailed confguration, but you can refer to web dispatcher cascade configuration.  play with the following parameters:
    wdisp/server_info_location
    wdisp/group_info_location
    wdisp/url_map_location
    >
    Cons wrote:
    > So in short, get your networking guys to do this, SAP cannot help in any way.
    it's not ture, web dispatcher can be used reverse proxy, of course you also can use other solution like Apache. However it's not recommened to use NAT, which might breach your network security.
    Cheers,
    Denny
    Edited by: Denny Liao on Jan 28, 2010 11:26 PM

  • Unable to forward requests from webserver

    I am trying to set-up iWS 6.0sp4 to forward requests to the application server but I always get not found as the webserver is just looking at its own document root. I have deployed the fortune ear (from 6.5) and can access that via the application servers own http server perfectly well. I have added the plugin package to the webserver and added the following into the magnus.conf
    Init fn="load-modules" shlib="<install_dir>/lib/webserver-plugin/solaris/iws/libpassthrough.so" funcs="init-passthrough,auth-passthrough,check-passthrough,service-passthrough" NativeThread="no"
    Init fn="init-passthrough"
    and to the obj.conf
    NameTrans fn="assign-name" from="(fortune/fortune/*)" name="passthrough"
    NameTrans fn="assign-name" from="(fortune/*)" name="passthrough"
    ObjectType fn="force-type" type="magnus-internal/passthrough"
    Service type="magnus-internal/passthrough" fn="service-passthrough" servers="http://<application server http listener>"
    Error reason="Bad Gateway" fn="send-error" uri="$docroot/badgateway.html"
    </Object>
    The webserver starts up without any errors but never forwards any requests what might I be doing wrong?

    I followed the instructions found in the App Server 7 documentation and everything worked fine.
    The instructions I followed are in the document found at this link:
    http://docs.sun.com/source/816-7156-10/agplugin.html#17655
    Just FYI...
    I also checked with Sun about why this process is now necessary and I asked about what happened to the web connector from 6.x. Sun had this reply:
    The Web Server Plug-in is the new web connector. It just hasn't been wrapped with an installation yet ... which is why it is tedious. The old Plug-in for 6.5 would ultimately have the same type of obj.conf entries. I'm not sure if there will be an installation wrapper for it once the Enterprise Edition is released.
    The Web Server Plug-in is different right now in that it doesn't 'know' about multiple instances yet. These are capabilities that will be introduced in the Enterprise Edition in March. Of course, that doesn't stop you from having multiple instances of the web server talking to multiple instances of the app server. It just means that the web server instances have to be directed to the app server instances rather than discovering them.

  • How to configure bea apache plugin to forward request from apache to bea se

    Hi,
    I have an apache server and a bea weblogic application server. For security reasons, I wold like to configure a bea plugin on the apache server to redirect the client http/https requests from the apache2 server to bea application server.
    I have gone through the bea documentation and configure my apache2 httpd.conf as follows
    LoadModule weblogic_module modules/mod_wl_20.so
    <IfModule mod_weblogic.c>
    WebLogicHost myweblogic.server.com
    WebLogicPort 7001
    MatchExpression *.jsp
    </IfModule>
    <Location /weblogic>
    WebLogicHost myweblogic.server.com
    WebLogicPort 7001
    SetHandler weblogic-handler
    PathTrim /weblogic
    </Location>
    Then Restarted the apache2 and tryied to acces bea application through http://myweblogic.server.com/weblogic/
    and http://myweblogic.server.com/something.jsp
    It did not work
    httpd is started propery.
    Any help would be highly apreciated
    Many Thanks
    Ushas Symon

    I have no experience with nginx and varnish and asking configuration problems regarding these products is perhaps beyond the scope of this forum.
    While configuring varnish, we are getting issues and unable to connect server from my browser if I change port 80.
    You did not describe the issues, but it is possible and very common that your IP Firewall is blocking access to ports other than 80 and 22. For testing, you can simply turn it off. If you do not know how, please post your OS distribution version first, as it all depends.

  • Session is lost when going from a servlet to a jsp

    Any help would be greatly appreciated.
              I can sucessfully go from my jsp page to the Servlet. When in the servlet I have a service method where I place the information from my form on the jsp on a bean. Then I do a session.setAttribute("aBean", aBean) to place the bean in the session. Then do a req.sendRedirect("my.jsp"). Watching it in the debugger, when we leave the servlet our session is cleared and when we do a jsp:usebean to get the bean session from the session it creates a new bean so all the information is gone that was there before. here is my usebean tag where we are getting it from scope,
              <jsp:useBean id="aBean" scope="session" class="com.MyBean"></jsp:useBean>
              Thanks, Trucker

    <jsp:useBean name="helper" scope="session" class=".."/>
              <jsp:useBean name="helper" scope="session" type=".."/>
              ·class="package.class"
              Instantiates a bean from a class, using the new keyword and the class constructor. The class must not be abstract and must have a public, no-argument constructor. The package and class name are case sensitive.
              ·type="package.class"
              If the bean already exists in the scope, gives the bean a data type other than the class from which it was instantiated. The value of type must be a superclass of class or an interface implemented by class.
              If you use type without class or beanName, no bean is instantiate
              In your case you already instantiated the bean “com.MyBean” in servlet and you set bean in session scope. But you are not accessing that bean from servlet. Instead of that you are crating a new bean instance by using class attribute of <jsp: useBean>. So if you want to access the bean already created in servlet you should use type attribute instead of class in <jsp: useBean>. So you have to change your code as follows.
              <jsp:useBean id="aBean" scope="session" type="com.MyBean"></jsp:useBean>
              Then you will not lose the bean created in servlet.
              - Navaneeth

  • How can a user scroll the resultset obtained from a servlet in a jsp page?

    Actually i am having a page where user has to select company name and for tht i am providing him with a button, and on clicking tht button a
    new search page is provided , and on mentioning the search criteria ,a servlet is fired which returns a list of companies(tbasically i am creating a session object of resultset type which stores the companies name), now the servlets again goes back to search page, and here i want 2 display the company names, i am able to display company names in my search page , but now i want my user to select one of the companies from tht servlet.
    for tht i need to tap the onMouseOver function of java SCript, C
    Can any one tell me how to write code for tht
    Thanking in Advance

    see https://addons.mozilla.org/en-US/thunderbird/addon/send-later-3/

  • Executing an executable from a servlet or a JSP

    Is it possible to call an executable from a servlet. Say I have a client server application and I want to start the client application from a servlet. What is the best way to do that?
    I know normal Java applications can use the Runtime to run an executable. Can a servlet do the same? What are the security implications, considering that the servlet will be accessed from a browser?
    Thanks for your help.

    A servlet is executed on the server, not the client. The client receives a response from the servlet which is usually plain text formatted as HTML and/or javascript.
    So can a servlet use the Runtime class? Sure, but on the SERVER, not on the client. Hence, the executable will need to be on the webserver, not on the client machine and it will execute on the webserver, not on the client.
    Maybe, your HTML formatted response can include an <applet> tag to trigger the browser to download an applet that may have access to call an executable. Maybe a trusted applet?

  • Can't forward request from Apache to Tomcat on second instance

    Hi,
    I am trying to create 2 separate environments (dev and test) on one powerful
    Unix server which has 2 network cards, 2 IP addresses, 2 server names...
    Using Apache 2.0.43 and Tomcat 4.1.29/JBoss 3.0.7, mod_jk 2.0.43
    on Solaris 9, Intranet environment.
    Everything is fine on the first instance,
    but on the second instance when I do http://server2,
    Apache still can't redirect to second Tomcat/JBoss:
    "Forbidden
    You don't have permission to access / on this server.
    Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
    Apache/2.0.48 (Unix) mod_jk2/2.0.2 Server at mopppgctxat1.pfizer.com Port 80"
    If I do http://server2:8080, getting it all right.
    I made all internal ports on the second instance different from the first:
    e.g. 8080->8180, 8009->8109, etc.
    Even tried to change "Listen <ip2>:80" to 81, same error.
    Curiously, jk2.properties is totally commented out.
    I haven't compiled mod_jk, just copied the binary from the 1st instance.
    Can that be a problem ?
    Any help is very appreciated.
    Thank you,
    Oleg.

    By trying and trying I got it to work .... long hours
    I removed the queue to queue option and the subscriber name from the subscriptions definition. And then I removed the destination-queue on the propagation schedule. Then it worked.
    Mette

  • Sendredirect() from a servlet to a jsp page

    Hi all,
    From word document, I have some links like this: http://localhost:8080/Test/GetFileServlet?Name=Peter&Age=12
    when I click on the link, the GetFileServlet will check for user authentication.
    If i haven't logged in yet, servlet will kick me to Login.jsp (jsf) to login. I use a servlet filter to filter users.
    Once logged in, the page backing bean of login.jsp (Login.java) will send me to output.jsp which is only accessable to authenitcated users.
    That works great......
    Here is the problem when I click on the same link again.. With that I'm expecting the Servlet to kick me straight to output.jsp of JSF
    However, it keeps kicking me back to the login.jsp instead of output.jsp...
    Here is my sendredirect code in servlet
    resp.sendRedirect("http://10.80.54.240:8080/Test/faces/Local/output.jsp?Name=Peter&Age=12);

    iT'S OK..i fixed it using dispatcher

Maybe you are looking for

  • Zenbe Lists - anyone here using it?

    If anyone here is a Zenbe Lists user I have a few basic questions on which I'd appreciate some advice please. I was unable to raise these via their ticketed support form, which appears to be broken. 1. found my lists OK on my PC using my Firefox web

  • Crawl Portal itself

    We are trying to crawl our portal in so it can be searched and when results are clicked it will take you to the page and not the content item. But we are having problems following community links and pages. has anyone done this? We are running 6.0 SP

  • 2008 macbook pro spinning ball and now won't completely start up.

    i woke my computer up this morning and it wouldn't respond. it started with the spinning rainbow pinwheel, but now it won't log in. the farthest it's gotten is the desktop but it's blank - no icons, dock, or top bar. is there a way to troubleshoot th

  • Join issue with procob

    Does anyone else that uses the pro*cob precompiler have and issue with it rejecting the ISO standard join syntax (see below) when running the procob against a cobol program? I have tried this in both 9.2 and 10.2 and neither one seem to allow it. Thi

  • Upgrading from MacOs 10.3.9 to tiger

    Hi Guys, I'm new to the forum, nice to know everyone of you I need to upgrade my system. Since i'm using a G4-1250 Mhz the software update application can't get me anyfurther than MacOS 10.3.9. Is there any way for me to upgrade my system in order to