Getting at Response data in a servlet filter??

Hi,
I'm hoping an expert would point me in the right direction.
I'm writing a filter that'll act like a proxy. It'll need to inspect the response data coming back from the server, and also forward the response data back to the browser.
As a first step, I've written a TestFilter that'll print the response data. When I go to print the response data in the TestFilter, it doesn't print anything! However, if I get print the contentLength of the response, it shows up as 3000!
I know response isn't null, as the page gets displayed on to the browser that makes the request.
How do I get at the response data?
Thanks,
--Sridhar
Here is the sample filter -
// HeaderFilter.java
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class HeaderFilter extends GenericFilter {
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain)
throws java.io.IOException, javax.servlet.ServletException {
ServletContext context = filterConfig.getServletContext();
HttpServletRequest request = (HttpServletRequest)req;
CharResponseWrapper wrapper = new CharResponseWrapper((HttpServletResponse)resp);
chain.doFilter(request, wrapper);
System.out.println("******RESPONSE INFO******");
System.out.println("The response is " + wrapper.toString());
class CharResponseWrapper extends HttpServletResponseWrapper {
private CharArrayWriter output;
public String toString() {
return output.toString();
public CharResponseWrapper(HttpServletResponse response){
super(response);
output = new CharArrayWriter();
public PrintWriter getWriter(){
return new PrintWriter(output);
// Here is the output...
******RESPONSE INFO******
The response is

I'm still baffled!!
Here is the output I see in the console when I expect to see a lot more. This is the behaviour under both JRun & Weblogic. It makes me think that I'm missing something subtle!
Could the experts point me in the right direction? This is really stumping me & the deadlines are looming large :(
Output is -
*** TEST FILTER ***
************** RESPONSE DATA ***********
[B@2fb7ef
Here is the test filter implementation -
// TestFilter.java
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
public class TestFilter extends GenericFilter {
public void doFilter(final ServletRequest request, final ServletResponse response, FilterChain chain) throws IOException, ServletException
System.out.println("*** TEST FILTER ***");
OutputStream out = response.getOutputStream();
TestResponseWrapper wrapper = new TestResponseWrapper((HttpServletResponse) response);
chain.doFilter(request, wrapper);
System.out.println("************** RESPONSE DATA ***********");
System.out.println(wrapper.getData());
out.write(wrapper.getData());
out.close();
// TestResponseWrapper.java
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
import java.io.ByteArrayOutputStream;
import java.io.PrintWriter;
public class TestResponseWrapper extends HttpServletResponseWrapper{   
private ByteArrayOutputStream output;
private int contentLength;
private String contentType;
public TestResponseWrapper(HttpServletResponse response) {       
super(response);
output = new ByteArrayOutputStream();
public ServletOutputStream getOutputStream() {       
return new FilterServletOutputStream(output);
public byte[] getData() {
return output.toByteArray();
public PrintWriter getWriter() {   
return new PrintWriter(getOutputStream(), true);
public void setContentType(String type) {       
this.contentType = type;
super.setContentType(type);
public String getContentType() {       
return this.contentType;
public int getContentLength() {    
return contentLength;
public void setContentLength(int length) {       
this.contentLength=length;
super.setContentLength(length);
// FilterOutputStream.java
import javax.servlet.ServletOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class FilterServletOutputStream extends ServletOutputStream {
private DataOutputStream stream;
public FilterServletOutputStream(OutputStream output) {       
stream = new DataOutputStream(output);
public void write(int b) throws IOException {       
stream.write(b);
public void write(byte[] b) throws IOException {       
stream.write(b);
public void write(byte[] b, int off, int len) throws IOException {       
stream.write(b, off, len);

Similar Messages

  • Trouble getting any response data

    Hi all,
    I have been having trouble with cref and CadDevice/CadDeviceInterface.
    I have my applet initialized and saved into a ROM; and then the ROM
    loaded is into cref. While cref waits for inputs I start an instance of
    CadDeviceInterface to exchange APDUs. The problem that I've been
    getting is that on selection the response is successful (0x9000)--
    but no data is contained in the response when it should contain
    the applet's AID.
    The other problems are function not found on reading data on the applet
    and on initializing parameter update.
    Does anyone knows what's the problem is here? I love any sort
    of suggestion.
    kl

    nevermind, i found the problem.

  • How to send a file from a java program to a servlet and get a response

    Hi,
    How can I call a servlet from a standalone java program and send a file to a servlet using POST method and in return gets the status back from the servlet. Any help is appreciated any small sample will help.
    Thanks.

    Hi,
    I am trying the following sample I got from net and am getting the following error. Any help what I am doing wrongs:
    06/12/24 02:15:58 org.apache.commons.fileupload.FileUploadBase$InvalidContentTypeException: the request doesn't contain a multipart/form-data or multipart/mixed stream, content type header is null
    06/12/24 02:15:58      at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:294)
    06/12/24 02:15:58      at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:268)
    06/12/24 02:15:58      at mypackage9.Servlet1.doPost(Servlet1.java:38)
    06/12/24 02:15:58      at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    06/12/24 02:15:58      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    06/12/24 02:15:58      at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
    06/12/24 02:15:58      at oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unknown Source)
    06/12/24 02:15:58      at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:663)
    06/12/24 02:15:58      at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:330)
    06/12/24 02:15:58      at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:830)
    06/12/24 02:15:58      at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:285)
    06/12/24 02:15:58      at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:126)
    06/12/24 02:15:58      at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
    06/12/24 02:15:58      at java.lang.Thread.run(Thread.java:534)Here is the sample client code:
    import org.apache.commons.httpclient.HttpClient;
    import org.apache.commons.httpclient.methods.PostMethod;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.IOException;
    public class PostAFile {
        private static String url =
             "http://192.168.0.17:8988/Vulcan_Materials-ServletPost2-context-root/servlet/Servlet1";
        public static void main(String[] args) throws IOException {
            HttpClient client = new HttpClient();
            PostMethod postMethod = new PostMethod(url);
            client.setConnectionTimeout(8000);
            File f = new File("C:\\load.txt");
            System.out.println("File Length = " + f.length());
            postMethod.setRequestBody(new FileInputStream(f));
            int statusCode1 = client.executeMethod(postMethod);
            System.out.println("statusLine>>>" + postMethod.getStatusLine());
            postMethod.releaseConnection();
    }Here is the sample servlet code:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.PrintWriter;
    import java.io.IOException;
    import org.apache.commons.fileupload.DiskFileUpload;
    import org.apache.commons.fileupload.FileItem;
    import java.util.List;
    import java.util.Iterator;
    import java.io.File;
    public class Servlet1 extends HttpServlet
      private static final String CONTENT_TYPE = "text/html; charset=windows-1252";
      public void init(ServletConfig config) throws ServletException
        super.init(config);
      public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
        try
          response.setContentType(CONTENT_TYPE);
          PrintWriter out = response.getWriter();
          java.util.Enumeration e= request.getHeaderNames();
            while (e.hasMoreElements()) {
              String headerName=(String)e.nextElement();
              System.out.println(headerName +" = "+request.getHeader(headerName));
           //System.out.println("Content Type ="+request.getContentType());
            DiskFileUpload fu = new DiskFileUpload();
            // If file size exceeds, a FileUploadException will be thrown
            fu.setSizeMax(1000000);
            List fileItems = fu.parseRequest(request);
            Iterator itr = fileItems.iterator();
    System.out.println("***************************");
            while(itr.hasNext()) {
              FileItem fi = (FileItem)itr.next();
              //Check if not form field so as to only handle the file inputs
              //else condition handles the submit button input
              if(!fi.isFormField())
                System.out.println("\nNAME: "+fi.getName());
                System.out.println("SIZE: "+fi.getSize());
                //System.out.println(fi.getOutputStream().toString());
                File fNew= new File("C:\\", fi.getName());
                System.out.println(fNew.getAbsolutePath());
                fi.write(fNew);
              else
                System.out.println("Field ="+fi.getFieldName());
            out.println("SUCCESS123456: ");
          out.close();
        catch(Exception e)
          e.printStackTrace();
    }Any help on what is wrong.
    Thanks

  • Getting FacesContext from a Servlet Filter

    I am trying to get at the FacesContext from within a servlet filter, but when I call this in the doFilter(request, response) method:
    FacesContext context = FacesContext.getCurrentInstance();
    context is null.
    Any ideas to get around this?

    Those links might be helpful for you:
    http://www.thoughtsabout.net/blog/archives/000033.html
    http://jroller.com/page/why/20050124
    Sergey : http://jsfTutorials.net

  • How can i get an Applet transfer data to a servlet like a Form does?

    it is clear that URL class provides way to connect to remote web resource. and furthermore i am trying to make an applet perform like a Form in html to send user data to a servlet. i may adhere a long name-value string to url sent by applet but this is not a good way to hide information like hidden variables. Is there any class in J2SE package that i can wrap those Form data and send them in the way Form does...?
    cheers!

    Double posted
    http://forum.java.sun.com/thread.jspa?threadID=578770&messageID=2913924#2913924
    In your other post:
    but i just don't want to build a string with serlet name followed by many NV pairs tthis is a GET request:
    myURL?name=value&name=value
    To use a POST
    http://javaalmanac.com/egs/java.net/Post.html
    This still requires you to make a VP string that you write to an outputstream of the
    URLConnection. There is no other way to do this unless in an applet.

  • Response completely written by servlet - how can a filter find out?

    hi!
    i am working on a servlet filter and i need to wait for the whole response to be written by the underlying servlet before the filter can start processing it.
    it's no problem, if the servlet closes the stream or writer at the end of the service method.
    But if it does not like in the following snippet, i am in trouble :-/
    out.println("html, html, html");
    out.println("</html>");
    // NO out.close();
    So my question is, is there any possibilty to check for the end of the service-method or something like that?
    It seems to be quite common, not to explicitely close the stream. even the most basic servlet tutorials don't do it very often. so i guess, i have to deal with this case.
    thanks in advance!

    hi!
    i am working on a servlet filter and i need to wait for the whole response to be written by the underlying servlet before the filter can start processing it.
    it's no problem, if the servlet closes the stream or writer at the end of the service method.
    But if it does not like in the following snippet, i am in trouble :-/
    out.println("html, html, html");
    out.println("</html>");
    // NO out.close();
    So my question is, is there any possibilty to check for the end of the service-method or something like that?
    It seems to be quite common, not to explicitely close the stream. even the most basic servlet tutorials don't do it very often. so i guess, i have to deal with this case.
    thanks in advance!

  • How to send data to another site, get response, redirect and get new response

    Dear all,
    I've to write a Java EE application that have to become an interface to a payment platform. The protocol require to send a POST string containing some information (including an error and response page) to an external host, get the response and redirect the user to another host using the previous response. When the user ends the transaction the host redirect the user to my error or response page.
    For the moment my user access to my application using glassfish REALM authentication. After that I write the following code:
    public void paymentPrepare() throws UnsupportedEncodingException, IOException {
       String postUrl = "https://test.payment.test/init/http";
       HttpPost postRequest = new HttpPost(postUrl);
       String id = "99999999";
       String password = "99999999";
       String action = "4";
       String amt = "1.00";
       String currencycode = "978";
       String langid = "ENG";
       String responseurl = "http://myhost:8080/EMBOWorkshop/secure/response.xhtml";
       String errorurl = "http://myhost:8080/EMBOWorkshop/secure/error.xhtml";
      trackid = "TRCK0001";
      udf1 = "Descrizione";
       StringEntity postParamsEntity = new StringEntity("id=" + id
       + "&password=" + password
       + "&action=" + action
       + "&amt=" + amt
       + "&currencycode=" + currencycode
       + "&langid=" + langid
       + "&responseurl=" + responseurl
       + "&errorurl" + errorurl
       + "&trackid" + trackid
       + "&udf1" + udf1);
      postParamsEntity.setContentType("application/x-www-form-urlencoded");
      postRequest.setEntity(postParamsEntity);
       DefaultHttpClient httpClient = new DefaultHttpClient();
       // Execute the HTTP POST
       System.out.println("Executing HTTP Post...\n");
       HttpResponse response = httpClient.execute(postRequest);
       // Check the HTTP status of the post.
       if (response.getStatusLine().getStatusCode() != 200 && response.getStatusLine().getStatusCode() != 201) {
       throw new RuntimeException("Failed: HTTP error code: "
       + response.getStatusLine().getStatusCode());
       // Create a reader to read in the HTTP post results.
       BufferedReader br = new BufferedReader(
       new InputStreamReader((response.getEntity().getContent())));
       // Read in all of the post results into a String.
       String output = "";
       Boolean keepGoing = true;
       while (keepGoing) {
       String currentLine = br.readLine();
       if (currentLine ==
    null) {
      keepGoing = false;
       } else {
      output += currentLine;
       System.out.println("Raw string result: \n" + output);
    The previous code works fine. I receive the response. But now I don't know how to continue. How can redirect the user to another site, and when the payment is finished, receive the response? Another question is, the user authenticate himself to access to the application. When the user will redirect to an external site, the glassfish session permits to get the response from the other host without require a new authentication?
    For the moment I don't know how to redirect the user, but I tried to write this method to obtain the last response:
      public void getResponse(HttpServletRequest request, HttpServletResponse response) {
      paymentId = request.getParameter("paymentid");
      result = request.getParameter("result");
      auth = request.getParameter("auth");
       ref = request.getParameter("ref");
      traind = request.getParameter("tranid");
      trackid = request.getParameter("trackid");
      udf1 = request.getParameter("udf1");
      responsecode = request.getParameter("responsecode");
    Is it correct?
    Thanks

    Now I'm able to redirect the user to the other page:
    ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
    externalContext.redirect("http://stackoverflow.com");
    Now the problem is: once the user has finished to pay, the other site redirect the user to my site using one of the two JSF page I prepared for error or response like the following:
    <?xml version='1.0' encoding='UTF-8' ?>
    <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                    template="./index.xhtml"
                    xmlns:h="http://java.sun.com/jsf/html"
                    xmlns:f="http://java.sun.com/jsf/core"
                    xmlns:rich="http://richfaces.org/rich"
                    xmlns:a4j="http://richfaces.org/a4j"
                    xmlns="http://www.w3.org/1999/xhtml"
                    xmlns:fn="http://java.sun.com/jsp/jstl/functions"
                    >
        <ui:define name="content">
            <center>
               An error occurred during  transaction
                #{participantBean.auth}<br />
                #{participantBean.responsecode}
            </center>
      </ui:define>
    </ui:composition>
    So, how can I get the GET parameters that the other host sent to me during the redirection?

  • Strange behavior when using servlet filter with simple index.htm

    I am new to J2EE development so please tolerate my ignorance. I have a web application that starts with a simple index.htm file. I am using a servlet filter throughout the website to check for session timeout, redirecting the user to a session expiration page if the session has timed out. When I do something as simple as loading the index.htm page in the browser, the .css file and one image file that are associated, or referenced in the file are somehow corrupted and not being rendered. How do I get the filter to ignore css and image files??? Thank you!!
    The servlet filter:
    import java.io.IOException;
    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class SessionTimeoutFilter implements Filter {
         String[] excludedPages = {"SessionExpired.jsp","index.htm","index.jsp"};
         String timeoutPage = "SessionExpired.jsp";
         public void destroy() {
         public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
              if ((request instanceof HttpServletRequest) && (response instanceof HttpServletResponse)) {
                   HttpServletRequest httpServletRequest = (HttpServletRequest) request;
                   HttpServletResponse httpServletResponse = (HttpServletResponse) response;
                   //httpServletResponse.setHeader("Cache-Control","no-cache");
                   //httpServletResponse.setHeader("Pragma","no-cache");
                   //httpServletResponse.setDateHeader ("Expires", 0);
                   String requestPath = httpServletRequest.getRequestURI();
                   boolean sessionInvalid = httpServletRequest.getSession().getAttribute("loginFlag") != "loggedIn";               
                   System.out.println(sessionInvalid);
                   boolean requestExcluded = false;
                   System.out.println(requestExcluded);
                   for (int i=0;i<excludedPages.length;i++){
                        if(requestPath.contains(excludedPages)){
                             requestExcluded = true;
                   if (sessionInvalid && !requestExcluded){
                        System.out.println("redirecting");
                        httpServletResponse.sendRedirect(timeoutPage);
              // pass the request along the filter chain
              chain.doFilter(request, response);
         public void init(FilterConfig arg0) throws ServletException {
              //System.out.println(arg0.getInitParameter("test-param"));
    The index.htm file (or the relevant portion)<HTML>
    <Head>
    <META http-equiv="Content-Style-Type" content="text/css">
    <LINK href="RTEStyleSheet.css" rel="stylesheet" type="text/css">
    <TITLE>Login</TITLE>
    </HEAD>
    <BODY>
    <FORM NAME="Login" METHOD="POST" ACTION="rte.ServletLDAP"><!-- Branding information -->
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
         <tr>
              <td width="30%" align="left"><img src="images/top_logo_new2.gif">
              </td>
              <td width="37%" align="center"></td>
              <td width="33%" align="right"></td>
         </tr>
    </table>
    My web.xml entry for the filter:     <filter>
              <description>
              Checks for a session timeout on each user request, redirects to logout if the session has expired.</description>
              <display-name>
              SessionTimeoutFilter</display-name>
              <filter-name>SessionTimeoutFilter</filter-name>
              <filter-class>SessionTimeoutFilter</filter-class>
              <init-param>
                   <param-name>test-param</param-name>
                   <param-value>this is a test parameter</param-value>
              </init-param>
         </filter>
         <filter-mapping>
              <filter-name>SessionTimeoutFilter</filter-name>
              <url-pattern>/*</url-pattern>
              <dispatcher>REQUEST</dispatcher>
              <dispatcher>FORWARD</dispatcher>
         </filter-mapping>

    Hi,
    Try adding CSS files and images to the excluded Pages.

  • How to get all the data stored on a table?

    Hi.
    I'm tryng to get all the data stored on a database table but I'm losing in trouble. I've looked for a soloution to my problem in the forums but each post I follow related to this issue gives me a different way to solve the problem and no one works :(
    I suppose I have to call the getAllRowsInRange() method from my ViewObject class. But how can I get an instance of my ApplicationModule in order to get the corresponding ViewObject?
    I think I messed my head a lot.
    Could someone help me please?
    Thanks in advance.

    Thanks for your answer.
    However, there are some things that I don't understand. I will look the book but why is necessary to create another ApplicationModule? The fact is that my application just have one ApplicationModule.
    Apart from that, I have tried your suggestion and I've obtained the quite little friendly response that follows:
    javax.faces.FacesException: #{backing_pruebaFilas.commandButton1_action}: javax.faces.el.EvaluationException: oracle.jbo.ConfigException: JBO-33001: No se ha encontrado el archivo de configuración /DatosViewObj/common/bc4j.xcfg en classpath
         at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:98)
         at javax.faces.component.UICommand.broadcast(UICommand.java:332)
         at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:287)
         at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:401)
         at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:95)
         at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
         at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:110)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:213)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.1) ].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._invokeDoFilter(AdfFacesFilterImpl.java:228)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._doFilterImpl(AdfFacesFilterImpl.java:197)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl.doFilter(AdfFacesFilterImpl.java:123)
         at oracle.adf.view.faces.webapp.AdfFacesFilter.doFilter(AdfFacesFilter.java:103)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.1) ].server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:15)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:162)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.1) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:620)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.1) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:369)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.1) ].server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:865)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.1) ].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:447)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.1) ].server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:215)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.1) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:117)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.1) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:110)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.1) ].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)
    Caused by: javax.faces.el.EvaluationException: oracle.jbo.ConfigException: JBO-33001: No se ha encontrado el archivo de configuración /DatosViewObj/common/bc4j.xcfg en classpath
         at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:150)
         at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:92)
         ... 24 more
    Caused by: oracle.jbo.ConfigException: JBO-33001: No se ha encontrado el archivo de configuración /DatosViewObj/common/bc4j.xcfg en classpath
         at oracle.jbo.client.Configuration.loadFromClassPath(Configuration.java:367)
         at oracle.jbo.common.ampool.PoolMgr.createPool(PoolMgr.java:284)
         at oracle.jbo.common.ampool.PoolMgr.findPool(PoolMgr.java:539)
         at oracle.jbo.common.ampool.ContextPoolManager.findPool(ContextPoolManager.java:165)
         at oracle.jbo.client.Configuration.createRootApplicationModule(Configuration.java:1498)
         at oracle.jbo.client.Configuration.createRootApplicationModule(Configuration.java:1476)
         at view.backing.PruebaFilas.commandButton1_action(PruebaFilas.java:100)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:146)
         ... 25 more
    At that point, I think a better explanation of my purpose could be helpful. What I'm trying to do is just create a simple page with a command button, and in its action method get all the data stored in the rows of the table. I've seen a possible solution that I understand:
    DCIteratorBinding iter = getIterator("DatosViewObj1Iterator");
    System.out.println("Iterator Binding: "+iter);
    int startRange = iter.getRangeSize();
    iter.setRangeSize(-1);
    Row[] rows = iter.getAllRowsInRange();
    iter.setRangeSize(startRange);
    but the problem is that I don't know what is the class the method getIterator belongs to.
    Could you help me with this last piece of code? If not, I accept, of course, any suggestion. I am absolutely stuck.
    Thanks and regards.

  • How to send a request and get a response through xml

    How to send a request and get a response through xml files?

    This is the code that works for me. Hope you find it useful.
         public static String sendHttpGetRequest(String endpoint, String requestParameters){
              String result = null;
              // Send a GET request to the servlet
              try{
                   // Send data
                   String urlStr = endpoint;
                   if (requestParameters != null && requestParameters.length () > 0){
                        urlStr += "?" + requestParameters;
                   URL url = new URL(urlStr);
                   HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                   conn.setRequestProperty("Accept", "application/xml");
                   // Get the response
                   BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                   StringBuffer sb = new StringBuffer();
                   String line;
                   while ((line = rd.readLine()) != null){
                        sb.append(line);
                   rd.close();
                   result = sb.toString();
              } catch (Exception e){
                   e.printStackTrace();
              return result;
         }

  • Memory leak in Servlet Filter handling?

    In Sun Web Server 6.1, I'm finding a memory leak when using servlet filters. I've even created a "no op" servlet filter. When it's registered, every 10000 hits or so to filtered static content will eat up about 5 to 10 MB of RAM. The JVM heap size doesn't increase.
    When I remove the filter, I've hit the same static page on the server 50000 times without seeing an increase in memory usage by the process.
    This is on Windows 2000, and I think the Sun Web Server 6.1 is SP1. I haven't tried SP2 yet.
    For reference, here's the filter I put in:
    public class NoOpFilter implements Filter
    public void init(FilterConfig arg0) throws ServletException {}
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
    chain.doFilter(request, response);
    public void destroy() {}
    }

    I found the bug. I get the memory leak if magnus.conf has either or both of the following entries:
    AdminLanguage en
    DefaultLanguage en
    If I delete the entries, the memory leak goes away. I suppose this should get fixed by Sun sometime. Maybe I'll figure out how to officially report the bug later.

  • Servlet Filter - Reading Request Error

    I have a servlet filter that sits in front of a webservice servlet (AXIS) - what I want the filter to do is to look at the content of the ServletRequest and if a particular string is located in the request, I want to call another service. Everything works just fine except (isin't there always an execept) that when I execute the following code in the filter:
    BufferedReader inReader = request.getReader();
    String line = null;
    StringBuffer sbuf = new StringBuffer();
    // Read the current request into a buffer
    while((line = inReader.readLine()) != null) {
    sbuf.append(line);
    sbuf.append("\n\r");
    if (sbuf.toString().indexOf("mystring") > -1) {
    // I do some code
    } else {
    chain.doFilter(request, wrapper);
    When I execute this code, at the chain.doFilter I get an "java.lang.IllegalStateException: getReader() has already been called for this request"
    I know that this is because I obtained the Reader from the request. But my question is - How can I look at the request string so that I can evaluate it and not have this exception thrown..
    Thx in advance...

    My guess is that when you do the chain.doFilter you pass the request to another resource that then tries to access the request.getInputStream method.
    From the JavaDocs:
    getReader
    public java.io.BufferedReader getReader()
    throws java.io.IOException
    Retrieves the body of the request as character data using a BufferedReader. The reader translates the character data according to the character encoding used on the body. Either this method or getInputStream() may be called to read the body, not both.
    Returns:
    a BufferedReader containing the body of the request
    Throws:
    java.io.UnsupportedEncodingException - if the character set encoding used is not supported and the text cannot be decoded
    IllegalStateException - if getInputStream() method has been called on this request
    java.io.IOException - if an input or output exception occurred

  • Request.setHeader in servlet filter

    Hi there,
    I am working on servlet filter to filter HttpServletRequest before sending it to the original servlet.
    The original servlet expects some content posted in the body of HttpServletRequest object.
    In my servlet filter, I need to modify this content (already done) and then doFilter to the origin.
    And here is the problem:
    The original servlet uses HTTP header's content-length value to read the entire content posted. But if I modify this content in my filter, it will never get correct content of the request.
    Unfortunately the original servlet is black boxed and there is no way to modify it.
    Is there any way to modify HTTP headers of HttpServletRequest in servlet filter?
    Thank you for any suggestions,
    mato_v

    Hum... ServletRequest.getHeader is read only, so you can't change them. There few solution you may try though:
    * Try create another wrapper instance of ServletRequest inside your filter and forward it to your black box servlet. You might have to wrote your own implementation to manipulate those Headers.
    * How about after you changed your data, redirect/post to your black box with the correct content? Use java.net.HttpURLConnection or a java Http client to do fancy posting if needed.
    Hope these helps.

  • Issues in getting Real Time data in BAM

    Hi,
    I am trying to get data from database through database adapter and push this data in a JMS queue and as a final step, I want to pull this data to BAM DATA OBJECTS.
    I have used a BPEL process and successfully pushed data to JMS queue from database. As a next step I have configured BAM ENTERPRISE MESSAGE SOURCES for Oracle AS JMS and OJMS as below--
    JMS*".;D:\OracleBAM\OC4J\j2ee\home\oc4j.jar;D:\OracleBAM\OC4J\j2ee\home\oc4jclient.jar;D:\OracleBAM\OC4J\j2ee\home\lib\oc4j-internal.jar;D:\OracleBAM\OC4J\j2ee\home\lib\ejb.jar;D:\OracleBAM\OC4J\j2ee\home\lib\servlet.jar;D:\OracleBAM\OC4J\j2ee\home\lib\jta.jar;D:\OracleBAM\OC4J\j2ee\home\lib\jms.jar;D:\OracleBAM\OC4J\j2ee\home\lib\javax88.jar;D:\OracleBAM\OC4J\j2ee\home\lib\javax77.jar;D:\OracleBAM\OC4J\j2ee\home\lib\jmxri.jar;D:\OracleBAM\OC4J\j2ee\home\lib\jmx_remote_api.jar;D:\OracleBAM\OC4J\j2ee\home\lib\adminclient.jar;D:\OracleBAM\OC4J\j2ee\home\ojspc.jar;D:\OracleBAM\OC4J\j2ee\home\jazn.jar;D:\OracleBAM\OC4J\opmn\lib\optic.jar;D:\OracleBAM\OC4J\rdbms\jlib\aqapi.jar"
    And I have also configured the message source in ARCHITECT as below-
    Initial Context Factory: com.evermind.server.ApplicationInitialContextFactory.
    JNDI Service Provider URL: opmn:ormi://punsez128189d.ad.infosys.com:6003/home.
    TopicConnectionFactory Name: jms/QueueConnectionFactory.
    Topic Name: jms/BamTesting.
    JMS Message Type: TextMessage.
    Durable Subscriber Name (Optional): BamClient.
    Message Selector (Optional): .
    Client ID (Optional): BamClient.
    I have made appropriate changes in oc4j-ra.xml and jndi.properties file. I have created a plan in DESIGN STUDIO with enterprise message receiver and a grid.
    After completing the above steps, I run the BPEL process and the plan, on doing so the data goes into the queue, but on running the plan i get the following error-
    IMessageSourceReceiver->messageReceive: javax.naming.NamingException: null should only be used inside OC4J server environments. Check the user documentation for the appropriate client initial context factory
         at com.evermind.server.PreemptiveApplicationContext.getContext(PreemptiveApplicationContext.java:25)
         at com.evermind.naming.FilterContext.lookup(FilterContext.java:126)
         at com.evermind.server.PreemptiveApplicationContext.lookup(PreemptiveApplicationContext.java:42)
         at javax.naming.InitialContext.lookup(InitialContext.java:347)
         at iteration.enterpriselink.sources.JMSConsumer.start(JMSConsumer.java:85)
         at iteration.enterpriselink.sources.JMSMessageSourceReceiverImpl.jmsConsumerStart(JMSMessageSourceReceiverImpl.java:1001)
         at iteration.enterpriselink.sources.JMSMessageSourceReceiverImpl.messageReceive(JMSMessageSourceReceiverImpl.java:326)
    [Oracle BAM Enterprise Link error code:  0x75 -- 0x1, 0x75 -- 0x3A]
    Error during Message Receive operation.
    [Oracle BAM Enterprise Link error code:  0x75 -- 0x1, 0x75 -- 0x3B]
    Error while processing the data for the step 'Oracle BAM Enterprise Message Receiver'
    [Oracle BAM Enterprise Link error code:  DC -- 0x1, DC -- 0x83]
    Error while processing the data for the step 'Oracle BAM Enterprise Message Receiver'
    [Oracle BAM Enterprise Link error code:  DC -- 0x1, DC -- 0x83]
    IMessageSourceReceiver->messageReceive: javax.naming.NamingException: null should only be used inside OC4J server environments. Check the user documentation for the appropriate client initial context factory
         at com.evermind.server.PreemptiveApplicationContext.getContext(PreemptiveApplicationContext.java:25)
         at com.evermind.naming.FilterContext.lookup(FilterContext.java:126)
         at com.evermind.server.PreemptiveApplicationContext.lookup(PreemptiveApplicationContext.java:42)
         at javax.naming.InitialContext.lookup(InitialContext.java:347)
         at iteration.enterpriselink.sources.JMSConsumer.start(JMSConsumer.java:85)
         at iteration.enterpriselink.sources.JMSMessageSourceReceiverImpl.jmsConsumerStart(JMSMessageSourceReceiverImpl.java:1001)
         at iteration.enterpriselink.sources.JMSMessageSourceReceiverImpl.messageReceive(JMSMessageSourceReceiverImpl.java:326)
    [Oracle BAM Enterprise Link error code:  0x75 -- 0x1, 0x75 -- 0x3A]
    Error during Message Receive operation.
    [Oracle BAM Enterprise Link error code:  0x75 -- 0x1, 0x75 -- 0x3B]
    Error while processing the data for the step 'Oracle BAM Enterprise Message Receiver'
    [Oracle BAM Enterprise Link error code:  DC -- 0x1, DC -- 0x83]
    Update of Plan "Untitled, created 4/25/2008 6:55:06 PM" failed.
    [Oracle BAM Enterprise Link error code:  PlanMgr -- 0x1, PlanMgr -- 0xD5]
    Could anyone suggest what might have gone wrong.
    Any help on this would be appreciated.

    Hi monteiro,
    Thanks for your reply
    my SOAP Request is :
    <?xml version="1.0" encoding="utf-8"?>
    http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://schemas.cisco.com/ast/soap/" xmlns:types="http://schemas.cisco.com/ast/soap/encodedTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    "http://schemas.cisco.com/ast/soap/action/#RisPort#SelectCmDevices"
    http://schemas.xmlsoap.org/soap/encoding/">
    10
    Any
    255
    Any
    Name
    SEP0017951612345
    SEP001320012346
    i am sending this message to String endPointUrl="https://ccmusername:ccmpassword@ccmPORTnumber:8443/realtimeservice/services/RisPort";
    for this message iam getting empty response from CCM.can u please tell me where iam doing wrong, it is very urgent for me
    Thanks in advanced
    Regard's
    Ravindra

  • Problem-Writing datas to a Servlet thro' URLConnection class

    Hi,
    Iam trying to post some string data to a servlet.
    The servlet reads 2 parameters from url.And reads the xml string message thro post method.
    So in the client program, I added those parameters to the URL directly like this,
    "http://localhost/servlet/test?action1=value1&action2=value2" ,and created url object .
    And using URLConnection iam trying to post the xml string.
    But the servlet does not read the parameter values.Is my approach is correct?
    client code:
    package test;
    import java.net.*;
    import java.io.*;
    import java.util.*;
    public class Testxml{
    public static void main(String ars[])
    String XML="<?xml version='1.0'?><Test><msg>test message</msg></Test>";
    String server="http://localhost/servlet/test";
    String encodeString = URLEncoder.encode("action1") + "=" + URLEncoder.encode("something1")+"&"+URLEncoder.encode("action2") + "=" + URLEncoder.encode("something2");
    try{
         URL u = new URL(server+"?"+encodeString);
         URLConnection uc = u.openConnection();
         uc.setDoOutput(true);
         uc.setUseCaches(false);
         uc.setRequestProperty("Content-type", "application/x-www-form-urlencoded");
         OutputStream out = uc.getOutputStream();
         PrintWriter wout = new PrintWriter(out);
         wout.write(alertXML);
         wout.flush();
         wout.close();
         System.out.println("finished");
         catch(Exception e) {
         System.out.println(e);
    Servlet code:
    package test;
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class test extends HttpServlet {
    public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
         performTask(req, res);
    public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
         performTask(req, res);
    public void performTask(HttpServletRequest request, HttpServletResponse response) {
         try{
    String action1=request.getParameter("action1");
    String action2=request.getParameter("action2");
    if(action1.equals("something1") && action1.equals("something2") )
         ServletInputStream in = request.getInputStream();
         byte[] buffer = new byte[1024];
         String xmlMsg = "";
         int len = in.read(buffer,0,buffer.length);
         if(len>0)
         while (len > 0 ){
                   xmlMsg += new String(buffer,0,len);
                   len = in.read(buffer);
         System.out.println("xml : "+xmlMsg);
    This is not working.Even,it does not invoke servlet.Is this approach is correct?.
    Thanx,
    Rahul.

    Hi,
    Did you get the answer to your problem? I am facing the same problem, so if you have the solution, please share the same.
    TIA
    Anup

Maybe you are looking for