Using servlet filters- to read the rsponse

Hi ,
In my web application i am displaying the final result as an xml in a jsp.Now what ever I am displaying to the user i want to get that as a string and store it in a database.
For this i think i have to get that from the response object, i just looking at the servlet filters , but i am not sure using the servlet filters is a good option or not.
And i am really not sure exactly how to use the filters.
Please somene help me with this , is there a way for this,Please let me know if you don't understand what i am trying to do, so that i explain in little more detail.

Not exact but close. Describes a filter that caches the response to disc:
http://www.onjava.com/pub/a/onjava/2003/11/19/filters.html?page=3

Similar Messages

  • DO we really use Servlet Filters in realtime applications where?

    DO we really use Servlet Filters in realtime applications where?
    Can any one give me somegood exampleor link where i can find required information.
    Regards
    Vijendra

    Yes people do use Servlet Filters in real applications. The most common usage is as a common entry point for security checks or for logging purposes.
    One thing you could do is search the forum for questions on filters. Often the poster has a problem that he believes can be solved using filters.
    If you want to learn how to develop filters check the Sun J2EE tutorial.

  • The college uses, E-bray, to read the E books from the library. The previous version of Firefox worked great with the plugin. When I upgraded to the next version of Firefox now the plugin will not work.

    E-bray is a reader that allows me to easily read the college's Library's selection of electronic media. I am running version 5.0 of Firefox and the other version worked fine. It may have been version 3, I think. I have version 3 in my download. Can I load this version back onto my lap or will this really mess things up?

    Try loading and using the add-on from this link: https://addons.mozilla.org/en-US/firefox/addon/add-on-compatibility-reporter/
    Many add-ons do in fact work if you force them to run. The procedure to roll-back is given in this article: [[installing previous versions of firefox]]
    Unfortunately the official Firefox policy is that you downgrade to 3.6 which is supported for a while longer, and not the now unsupported Firefox 4. If after installing and running the ''add-on compatibility reporter'' you still have problems there are ways around the official policy.
    I think it is absurd that Firefox 4 may be used by tens of millions of users one day and a few days later those that upgrade to Firefox 5 should be not only told not to use a now unsupported browser, if they need to revert due to problems, but are actually obstructed in attempts to do so. See also [/questions/840397#answer-205154]

  • What is font book used for? I read the description but still unsure. Does it contain fonts that are not already on the computer

    What can I use font book for? I read the description but still don't get it. Does it contain fonts that are not already installed on my new Mac? Thanks.

    Disabling (turning off) a font will make it unavailable for use in any font menu. You can alwasy enable the font(s) again - they're not gone permanantly. DON'T disable System fonts, though -> that's just asking for trouble.
    Here's -> https://www.youtube.com/watch?v=JdR6-4lnF5A - a good video tutorial about using Font Book.
    Clinton

  • Can't use certain filters- "problem with the filter module interface"

    Hello,
    I frequently use the BPelt Flatten and Multifill plugins and they have always worked perfectly until today. Now I get the following error: "Could not complete the [Multifill/Flatten] command because of a problem with the filter module interface."
    I use Photoshop CS6 Extended with the Creative Cloud membership, and just recently updated to version 13.1.1 x64. I believe this may be related, as the plugins worked before the update and nothing else has changed.  Any recommendations on how to fix this? Is it possible to undo  the update?

    Usually this means a bug in the third party plugin that you are using.

  • Question about using JavaMail API to read the calendar folder...

    Hi,
    I've made an application that goes to the mail server, fetches all mails in the calendar folder and tells you the meetings you have in a particular day.
    I'm using JavaMail API for this. My problem is that the application is very slow because I'm forced to fetch (one by one!) the contents of every message.
    My question is: How can Outlook show so fast the mettings you have? Do they have a specific API that allows them to get the right info by only calling certain methods? Is there something similar in Java?
    Thaks for your help!
    Note: I use method:
    folder.fetch(allMessages, fetchProfile);howerver the fetchProfile class does not allow me to specfy that I want to dowload the contents of the message (you only can specify the content_info); specifying all headears does not help me either.

    Clarification:
    The VI you have posted will work as following:
    1) The task will read 2 analog inputs (ai0, ai3).
    2) The acquisition starts, oncece digital signal (trigger) is detected on PFI0
    3) The sampling rate will be as specified in "rate" control - it is continuous analog input acquisition, which means that after trigger is received (point 2), the board will start to generate hardware clock with frequency you specify as "rate"
    4) with each rising edge of that hardware clock, the measurement is taken, and stored into buffer of driver.
    5) DAQmx read will try to read "number of samples per channel" number of samples each time is called - and if there is not enough measurement stored in buffer (step 4), then DAQmx read will wait until DAQ card will measure reaquested number of samples (or timeout occurs before requested number of samples has been acquired)
    6) DAQmx read will be then called 1000 times - so totaly you will read 1000 * "number of samples per channel"  number of samples.
    You do not have to be worried about speed of the loop. In fact, if you need to read just 1000 samples, with 1kS/s, then you can remove for loop and you can change measurement mode from continuous to finite samples, and specify number of samples to read to be 1000. You will read them all properly. I recomend you to read User Manual for your DAQ device - lets say M Series User Manual.
    I hope it is clear now.
    regards,
    stefo

  • How to parse the xml file using servlet

    My scenario is like this:
    <b>FILE-->XI-->J2EE Application</b>
    XI sends the xml file to j2ee application. My servlet receives the file in HTTPRequest string. 
    How to parse that file using servlets.I should get the xml file as it is and should be displayed in the browser.
    Can anyone please help me with code, its urgent.
    Please help me!

    Download this java code
    http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/sax/work/Echo02.java
    in your servlet code you can write
    public void doPost(req,resp){
    DefaultHandler handler = new Echo02();
    handler.parse(req.getInputStream());
    Offcourse you will need to modify the code of Echo02 class a bit to suit your requirement which would finally retrun you a string and you can then write it using
    respose.getWriter().write(responseString);

  • Why is the iPad air being derided.  Love the simplicity of use and ease of reading newspaper.  Princepony

    Why is IPad Air being derided.  Love the simplicity of use and ease of reading the newspaper.  Princepony.

    national newspaper had article on falling sales of IPads due to popularity of smart phones.  Article said "only losers use IPads".  Failed to agree! Princepony

  • Will Servlet Filters affect performance

    Hi,
    is it true that Servlet Filters will have impact on Web application performance by slowing things? any suggestion plz..
    Regards,
    A.

    The question "Will X affect performance" is almost always bogus.
    It only makes sense to compare the performance of two code bases that perform a certain predetermined task. In your case, you could make your question not be bogus by comparing an application that uses servlet filters with another application that performs the same functions in a different way. You don't seem to be prepared to do that.

  • Using Servlets in java studio creator

    Hello, anyone can tell me how can i use a servlet in java studio creator, due the file is in .java i dont know how to use it, here is an example i want to add to my proyect:
    and other question is how can i make to work?
    * Sean C. Sullivan
    * June 2003
    * URL: http://www.seansullivan.com/
    package pdfservlet;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.io.ByteArrayOutputStream;
    import java.io.PrintWriter;
    // import the iText packages
    import com.lowagie.text.*;
    import com.lowagie.text.pdf.*;
    * a servlet that will generate a PDF document
    * and send the document to the client via the
    * ServletOutputStream
    * @author Sean C. Sullivan
    public class PDFServlet extends HttpServlet
         public PDFServlet()
              super();
         * we implement doGet so that this servlet will process all
         * HTTP GET requests
         * @param req HTTP request object
         * @param resp HTTP response object
         public void doGet(HttpServletRequest req, HttpServletResponse resp)
              throws javax.servlet.ServletException, java.io.IOException
              DocumentException ex = null;
              ByteArrayOutputStream baosPDF = null;
              try
                   baosPDF = generatePDFDocumentBytes(req, this.getServletContext());
                   StringBuffer sbFilename = new StringBuffer();
                   sbFilename.append("filename_");
                   sbFilename.append(System.currentTimeMillis());
                   sbFilename.append(".pdf");
                   // Note:
                   // It is important to set the HTTP response headers
                   // before writing data to the servlet's OutputStream
                   // Read the HTTP 1.1 specification for full details
                   // about the Cache-Control header
                   resp.setHeader("Cache-Control", "max-age=30");
                   resp.setContentType("application/pdf");
                   // The Content-disposition header is explained
                   // in RFC 2183
                   // http://www.ietf.org/rfc/rfc2183.txt
                   // The Content-disposition value will be in one of
                   // two forms:
                   // 1) inline; filename=foobar.pdf
                   // 2) attachment; filename=foobar.pdf
                   // In this servlet, we use "inline"
                   StringBuffer sbContentDispValue = new StringBuffer();
                   sbContentDispValue.append("inline");
                   sbContentDispValue.append("; filename=");
                   sbContentDispValue.append(sbFilename);
                   resp.setHeader(
                        "Content-disposition",
                        sbContentDispValue.toString());
                   resp.setContentLength(baosPDF.size());
                   ServletOutputStream sos;
                   sos = resp.getOutputStream();
                   baosPDF.writeTo(sos);
                   sos.flush();
              catch (DocumentException dex)
                   resp.setContentType("text/html");
                   PrintWriter writer = resp.getWriter();
                   writer.println(
                             this.getClass().getName()
                             + " caught an exception: "
                             + dex.getClass().getName()
                             + "<br>");
                   writer.println("<pre>");
                   dex.printStackTrace(writer);
                   writer.println("</pre>");
              finally
                   if (baosPDF != null)
                        baosPDF.reset();
         * @param req must be non-null
         * @return a non-null output stream. The output stream contains
         * the bytes for the PDF document
         * @throws DocumentException
         protected ByteArrayOutputStream generatePDFDocumentBytes(
              final HttpServletRequest req,
              final ServletContext ctx)
              throws DocumentException
              Document doc = new Document();
              ByteArrayOutputStream baosPDF = new ByteArrayOutputStream();
              PdfWriter docWriter = null;
              try
                   docWriter = PdfWriter.getInstance(doc, baosPDF);
                   doc.addAuthor(this.getClass().getName());
                   doc.addCreationDate();
                   doc.addProducer();
                   doc.addCreator(this.getClass().getName());
                   doc.addTitle("This is a title.");
                   doc.addKeywords("pdf, itext, Java, open source, http");
                   doc.setPageSize(PageSize.LETTER);
                   HeaderFooter footer = new HeaderFooter(
                                       new Phrase("This is a footer."),
                                       false);
                   doc.setFooter(footer);
                   doc.open();
                   doc.add(new Paragraph(
                                  "This document was created by a class named: "
                                  + this.getClass().getName()));
                   doc.add(new Paragraph(
                                  "This document was created on "
                                  + new java.util.Date()));
                   String strServerInfo = ctx.getServerInfo();
                   if (strServerInfo != null)
                        doc.add(new Paragraph(
                                  "Servlet engine: " + strServerInfo));
                   doc.add(new Paragraph(
                                  "This is a multi-page document."));
                   doc.add( makeGeneralRequestDetailsElement(req) );
                   doc.newPage();
                   doc.add( makeHTTPHeaderInfoElement(req) );
                   doc.newPage();
                   doc.add( makeHTTPParameterInfoElement(req) );
              catch (DocumentException dex)
                   baosPDF.reset();
                   throw dex;
              finally
                   if (doc != null)
                        doc.close();
                   if (docWriter != null)
                        docWriter.close();
              if (baosPDF.size() < 1)
                   throw new DocumentException(
                        "document has "
                        + baosPDF.size()
                        + " bytes");          
              return baosPDF;
         * @param req HTTP request object
         * @return an iText Element object
         protected Element makeHTTPHeaderInfoElement(final HttpServletRequest req)
              Map mapHeaders = new java.util.TreeMap();
              Enumeration enumHeaderNames = req.getHeaderNames();
              while (enumHeaderNames.hasMoreElements())
                   String strHeaderName = (String) enumHeaderNames.nextElement();
                   String strHeaderValue = req.getHeader(strHeaderName);
                   if (strHeaderValue == null)
                        strHeaderValue = "";
                   mapHeaders.put(strHeaderName, strHeaderValue);
              Table tab = makeTableFromMap(
                        "HTTP header name",
                        "HTTP header value",
                        mapHeaders);
              return (Element) tab;
         * @param req HTTP request object
         * @return an iText Element object
         protected Element makeGeneralRequestDetailsElement(
                                  final HttpServletRequest req)
              Map mapRequestDetails = new TreeMap();
              mapRequestDetails.put("Scheme", req.getScheme());
              mapRequestDetails.put("HTTP method", req.getMethod());
              mapRequestDetails.put("AuthType", req.getAuthType());
              mapRequestDetails.put("QueryString", req.getQueryString());
              mapRequestDetails.put("ContextPath", req.getContextPath());
              mapRequestDetails.put("Request URI", req.getRequestURI());
              mapRequestDetails.put("Protocol", req.getProtocol());
              mapRequestDetails.put("Remote address", req.getRemoteAddr());
              mapRequestDetails.put("Remote host", req.getRemoteHost());
              mapRequestDetails.put("Server name", req.getServerName());
              mapRequestDetails.put("Server port", "" + req.getServerPort());
              mapRequestDetails.put("Preferred locale", req.getLocale().toString());
              Table tab = null;
              tab = makeTableFromMap(
                                  "Request info",
                                  "Value",
                                  mapRequestDetails);
              return (Element) tab;
         * @param req HTTP request object
         * @return an iText Element object
         protected Element makeHTTPParameterInfoElement(
                             final HttpServletRequest req)
              Map mapParameters = null;
              mapParameters = new java.util.TreeMap(req.getParameterMap());
              Table tab = null;
              tab = makeTableFromMap(
                        "HTTP parameter name",
                        "HTTP parameter value",
                        mapParameters);
              return (Element) tab;
         * @param firstColumnTitle
         * @param secondColumnTitle
         * @param m map containing the data for column 1 and column 2
         * @return an iText Table
         private static Table makeTableFromMap(
                   final String firstColumnTitle,
                   final String secondColumnTitle,
                   final java.util.Map m)
              Table tab = null;
              try
                   tab = new Table(2 /* columns */);
              catch (BadElementException ex)
                   throw new RuntimeException(ex);
              tab.setBorderWidth(1.0f);
              tab.setPadding(5);
              tab.setSpacing(5);
              tab.addCell(new Cell(firstColumnTitle));
              tab.addCell(new Cell(secondColumnTitle));
              tab.endHeaders();
              if (m.keySet().size() == 0)
                   Cell c = new Cell("none");
                   c.setColspan(tab.columns());
                   tab.addCell(c);
              else
                   Iterator iter = m.keySet().iterator();
                   while (iter.hasNext())
                        String strName = (String) iter.next();
                        Object value = m.get(strName);
                        String strValue = null;
                        if (value == null)
                             strValue = "";
                        else if (value instanceof String[])
                             String[] aValues = (String[]) value;
                             strValue = aValues[0];
                        else
                             strValue = value.toString();
                        tab.addCell(new Cell(strName));
                        tab.addCell(new Cell(strValue));
              return tab;
    }

    Hi, i've done all described in the posts, but i
    don't know how to call the servlet, using the web
    browser, and more, how can i call the servlet frrom
    a button action? or hyperlink?
    nks for the helpOk, I am not sure what you are trying to do. For these events you can
    use the SessionBean. What do you want the servlet to do that the session bean can't?
    I use the sessionbean because I don't know how to receive or respond to xmlhttpreq messages directly in my sessionbean. If you just need the standard http req/resp it doesn't seem like a servlet is needed.

  • Error in Oracle 10g (10.0.3) in Servlet Filtering

    Hi
    I found this error on oracle 10g (10.0.3) Version. my same code is working on 9.0.4 can you please tell what is the problem? I am using servlet filtering.
    Mine is swing base application which will call applet and this will call Servlet.
    500 Internal Server Error
    java.lang.IllegalStateException: dispatcher chain is empty
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.0.3.0.0) - Developer Preview].server.http.EvermindHttpServletRequest.getCurrentDispatcher(EvermindHttpServletRequest.java:3975)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.0.3.0.0) - Developer Preview].server.http.EvermindHttpServletRequest.getParameters(EvermindHttpServletRequest.java:1393)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.0.3.0.0) - Developer Preview].server.http.EvermindHttpServletRequest.getParameter(EvermindHttpServletRequest.java:2126)
         at com.fmr.cfit.security.IdentityAgent.getUserIdFromParameter(Unknown Source)
         at com.fmr.cfit.security.IdentityAgent.getUserId(Unknown Source)
         at com.fmr.cfit.security.IdentityAgent.doFilter(Unknown Source)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.0.3.0.0) - Developer Preview].server.http.FileRequestDispatcher.handleWithFilter(FileRequestDispatcher.java:130)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.0.3.0.0) - Developer Preview].server.http.FileRequestDispatcher.forwardInternal(FileRequestDispatcher.java:210)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.0.3.0.0) - Developer Preview].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:824)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.0.3.0.0) - Developer Preview].server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.0.3.0.0) - Developer Preview].server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.0.3.0.0) - Developer Preview].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:291)
         at java.lang.Thread.run(Unknown Source)

    I am able to resolve the issue:
    The mistake I was doing was creating ORACLE_HOME in the enviornment variable, as I have Oracle 10 G database and SOA suite on the same machine, so it was creating a clash, the right approach is setting the ORACLE_HOME through command prompt, I was setting ORACLE_HOME because while executing the configure_oid.bat file it requires ORACLE_HOME to be set.
    -Yatan

  • Sending thumbnail of images to client on request using servlet/jsp

    hi
    can anybody tell me how can we send thumbnail of more than one image to client using servlet or jsp just the way we thumbnail of images in google

    Then create a servlet which uses Java 2D API to rezise the image and writes it to the outputstream of the response. Call that servlet in the <img> tag along with an unique request parameter identifying the image.

  • When to Use Servlet only, EJB only and, both Servlet And EJB???

    I have a question, If I want to build a Web application. Sometime i found that there is no need to use EJB as Servlet already provide that functionality.
    Can anyone tell me when do I use Pure Servlet? When do I use Pure EJB and, When do I use Both EJB and Servlet???
    I am very interesting in it.
    Thanks.
    Jack

    EJB and servlets are two different things. Trying to compare them doesn't really make sense. A web application is always going to need some way to process Http requests and this in Java is done accomplished through Servlets (or jsp pages which in turn also use servlets).
    EJBs are the basis of distributed cross-platform objects. They are handled through name services and stored in databases. An Entity Bean can be "brought back to life" as long as it's info is stored in a database. Regardless of a server being restarted. All this database support behind an Entity Bean (transactions, queries etc.) are very transparent to the programmer. They are provided by the EJB vendor.
    The class properties of a Servlet (or class-level member variables) are shared among all requests (running thread instances of the service method). That's why they should be used with a lot of caution. This feature can be very useful but if used improperly can also be very vulnerable to security and synchronization issues.
    I'm not an EJB expert but this explanation should give you some idea of what EJBs are all about.

  • How do I read  the Deployment descriptor throw my application?

    Hi
    There is a need for me to read attributes in the Deployment descriptor through my application.
    How may I do that? I don't want to use a Parsa to read the XML file and get the attributes..
    Is there any other way?
    thanks
    Sanesh

    All attributes or just the context parameters?
    For example:
    <context-param>
    <param-name>dbDriverName</param-name>
    <param-value>org.gjt.mm.mysql.Driver</param-value>
    <description>The database driver being used</description>
    </context-param>
    Could be read from your servlet with:
    String dbDriverName = servletContext.getInitParameter("dbDriverName");
    But if you'd like to get out the servlet mappings or anything else I guess you have to read and parse the file. There was a method called getServletNames() in the servlet context but that's deprecated now.

  • Getting absolute path of a file in a webapp without using servlet/JSP

    Hi all,
    I need a small clarification. Is it possible to reterive the absolute path of a file present in a tomcat web application without using Servlet/JSP. I have a normal java class which uses this file to read the configuration parameters. I like to know whether I need to create a seperate servlet which will read the parameters from web.xml.

    Hi all,
    I need a small clarification. Is it possible to
    reterive the absolute path of a file present in a
    tomcat web application without using Servlet/JSP. What if the file is in a WAR? What do you do then?
    I
    have a normal java class which uses this file to
    read the configuration parameters. There are other, better ways to do this.
    I like to know
    whether I need to create a seperate servlet which
    will read the parameters from web.xml.What do you really want it for? You shouldn't need an absolute path. Use the class loader to get an InputStream.
    %

Maybe you are looking for

  • Creation of followup task with a time delay.

    Hi experts, We are configurating a scenario where in a activity should generate a followup task automatically after 30 min. I have configured the above using the action profile and date profile. I have used the start condition as :           & planne

  • Attachment to workitem

    Hi, I need to attach a document to user decision step and i have converted the document to Xstring and generated the SOFM instance. Now i am binding this SOFM instance to "_ATTACH_OBJETCS" of UD step. I am getting the attachment link in UD but when i

  • What is the "easy" way to get to 3.1.2?

    I've "loved" the Oracle database for many years, and is thrilled with Apex. I no longer work as a DBA, but tries to keep my technical stuff close. I have an Apex 2.1 installation on an 10g database on Ubuntu 8.10 server. I did the lazy install then,

  • Counter negative cache hits and long searches

    hi my name is sumit. In my network there is a frame-relay pvc on 7206 VXR router on which 2 T1's are terminated(from S8700 EPABX) and the bandwidth of this PVC is 600 KBPS. we are using rtp and tcp header compression technique(codec g729r8).7206 rout

  • Windows thinks the mobile device helper isnt working - idoit!

    every time i get into itunes windows pops this message up saying that the apple mobile device helper has stopped working , but i can update my ipod and ive tryed the services directoty start/stop function for the helper. ive updated everything i can