Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Forward http request from Sevlet to Package Procedure

Re: Forward http request from Sevlet to Package Procedure

From: Art <ajs5mz2_at_yahoo.com>
Date: 18 Nov 2002 04:41:42 -0800
Message-ID: <28874e4d.0211180441.5a71a817@posting.google.com>


Vladimir,

I do some preprocessing then setup some attributes to pass the data back from the servlet to the package.

There has to be a way to get PL/SQL and java to talk to each other. I know I'm not the first person to try this.

Anyway: Here is the code in question

 public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // this.dumpParametersSorted(request,response);

     TreeMap map = new TreeMap();
     Enumeration keys = request.getParameterNames();
     while (keys.hasMoreElements()) {
         String key = (String) keys.nextElement();
         map.put(key,(String) request.getParameter(key));

}

    TreeMap sortedSites = new TreeMap();     TreeMap sortedDates = new TreeMap();

     
     Set sortedkeys = map.keySet();
     Iterator i = sortedkeys.iterator();
     while (i.hasNext()) {
        String key   = (String) i.next();
        String value = (String) request.getParameter(key);
        String idx = null;
        if (key.lastIndexOf("_") != -1) {
           idx = key.substring(key.lastIndexOf("_")+1,key.length());
        } 
        if (key.startsWith("site_appl_arr_")) {
           sortedSites.put(idx,value);
           System.err.print("Key  = "+key+"  index = "+idx+"  value =
"+value+"\n");
        }
        else if (key.startsWith("adapt_date_arr_")) {
          if ((value != null) && (value.length() > 5)) {
              sortedDates.put(idx,value);
             System.err.print("Key  = "+key+"  index = "+idx+"  value
= "+value+"\n");
          }            
        }

}

    String site_appl_arr = this.getStringList(sortedSites);     String adapt_date_arr = this.getStringList(sortedDates);

    System.err.print("\nsite_appl_arr \n"+site_appl_arr);     System.err.print("\nadapt_date_arr \n "+adapt_date_arr);

    request.setAttribute("site_appl_arr",site_appl_arr);     request.setAttribute("adapt_date_arr",adapt_date_arr);

    RequestDispatcher disp =
request.getRequestDispatcher("http://oastest.md.myserver.com/orat/plsql/w_cm_updt.doc_expeditor");

    disp.forward(request,response);    

 }

You can see where I'm using a RequestDispatcher.forward to send the request and reponse object to PL/SQL.

Any help here would be greatly appriciated.

Art   

"Vladimir M. Zakharychev" <bob_at_dpsp-yes.com> wrote in message news:<aqov7s$mf5$1_at_babylon.agtel.net>...

> Not sure this is the right NG to ask, .misc looks more like it.
> Anyway, without seeing a snippet of your servlet code and
> possibly package specification it's hard to say why this doesn't
> work. How are you passing control to the package? Do you
> call it via JDBC or are you attempting to redirect the client
> to the right place after you're done with that extra processing?
> 
> If you work through JDBC, then you gotta emulate PL/SQL
> gateway (mod_plsql) in your servlet (set up environment,
> call the package procedure and pass it relevant parameters,
> collect package output and stream it to the client) if your
> package uses OWA and outputs anything to the client, 
> otherwise it's pretty safe to simply call the procedure through
> JDBC and supply all relevant data to it.
> 
> If you do some preprocessing and then redirect client browser
> to the new location I don't see why it shouldn't work except
> for one tricky issue: there are actually three HTTP 1.1 status
> codes that do redirection - 302, 303 and 307, while in HTTP 1.0
> there was only 302. 302 means "redo your request to this new
> location preserving the method" while 303 means "GET response
> from this new location" and 307 means practically the same as
> 302. Regretably, most browsers behave on 302 the way they
> should for 303 - they GET the new location no matter the 
> method they used originally (so if original method was POST,
> 302 will cause GET on new location instead of POST with the
> same data), especially if the protocol in use is HTTP 1.0.
> So you actually should use 307 code in your response and
> hope that the browser on the other side understands HTTP 1.1.
> Take a look at RFC 2616 (http://www.ietf.org/rfc/rfc2616.txt)
> for more details on HTTP status codes and expected user agent
> behavior.
> 
> hth.
> 
> -- 
> Vladimir Zakharychev (bob@dpsp-yes.com)                http://www.dpsp-yes.com
> Dynamic PSP(tm) - the first true RAD toolkit for Oracle-based internet applications.
> All opinions are mine and do not necessarily go in line with those of my employer.
> 
> 
> "Art" <ajs5mz2_at_yahoo.com> wrote in message news:28874e4d.0211111008.6765ec35_at_posting.google.com...
> > Hi,
> > 
> > I'm trying to foward an http request from a servlet to an Oracle
> > Package Procedure. The package in question is an update package the
> > normally processes a forms post method.
> > 
> > I have redireced the forms post method the a java servelt for some
> > additional processing and would like to pass the request to the
> > package procedure.
> > 
> > Is this possible? Are there some special contraints that must be met
> > to allow this to work?
> > 
> > The oracle package procedure response to the http request coming
> > directly from a form just fine but it does not respond to a request
> > coming from a servlet.
> > 
> > Thanks,
> > 
> > Art
Received on Mon Nov 18 2002 - 06:41:42 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US