Filtering content returned by Servlet?

Hi, I've written a filter simply adds in an extra header before making the request to the final web server. This works fine. My question is, is it possible to modify the returned content before passing it back to the original client?
I don't have control over the webserver, just the filter. I would like to convert certain characters in the content returned by the server. Not sure if this is possible. One thing I tried was to create a URL object in the filter and use the URL.getContent() method. The idea was that I could read the content, modify it, write it back the response object and then commit the response. Problem is, when I create the URL object and request the content, it goes through my own filter again and then we're into an infinte loop...
Is there a way to specify to bypass my filter in the URL.connect() call? Can you think of any other way to program what I'm trying to do?
Thanks in advance...
Stuart.

It's supposed to be an infinite loop, because filter works before the request is passed to the servlet, like this:
http request -> filter -> servlet/JSP -> http response
and your filter does the whole process above so this is a recursion, without and escape-condition.
So if just want a filter's work, don't use the URL object, just work with the request object. Get the parameters in the request and process them, then put the result in a bean into the request object. Finally, the requested servlet gets the request object and proccess the bean the filter created and generate the response whatever you want it to be.
Does this help?

Similar Messages

  • How to set content type in servlet?

    Hi, there,
    I'm writing a servlet to use ObjectOutputStream to return an object to applet. How can I set this content type in servlet?
    Thanks.

    Actually, I'm writing a "HashMap" from servlet to applet. I have used your suggested content type "application/octet-stream" and another "appication/x-java-serialized-object" to try it. But in applet side, when I use (HashMap)in.readObject(), it always gives me a exception as:"java.util.HashMap; IllegalAccessException". Why?
    Thankd.

  • Filtering Content on a Page?

    Hey guys, I've found myself in a bit of a quandary.
    A client wanted me to design a responsive (Though he didn't know that was the word at the time) website for his new restaurant. He wanted the user to be able to do things such as order their food online, contact us and book the restaurant as a venue. There were other elements of course but those were the three main features he wanted.
    I accepted the job as it seemed easy enough.
    What I didn't realise though was the size of his menu. He did of course mention that he had a larger than average menu but that he managed to split it up into a "Few" different sections (Such as "Starters", "Salads", "Breads".
    It turns out that a "Few" sections turned out to be over a dozen, meaning over a hundred different pieces of food. When he told me that his menu was larger than average I thought about having the button "Order Online" on the navigation bar with a drop down menu leading to different pages, each contain one section of the menu. Of course, I can't do that when there are over 12 different sections because then it looks completely stupid.
    I now need some way to actually display it on the webpage. So I decided on like a mini navigation bar within the page itself located to the left of the main body. This navigation bar (Vertical and taking up less than a fifth of the screen) should control what is shown on the right side.
    The page itself shouldn't have to reload, rather only the small section on the right.
    Thanks for the help guys.

    ashton knight wrote:
    Hey guys, I've found myself in a bit of a quandary.
    A client wanted me to design a responsive (Though he didn't know that was the word at the time) website for his new restaurant. He wanted the user to be able to do things such as order their food online, contact us and book the restaurant as a venue. There were other elements of course but those were the three main features he wanted.
    I accepted the job as it seemed easy enough.
    What I didn't realise though was the size of his menu. He did of course mention that he had a larger than average menu but that he managed to split it up into a "Few" different sections (Such as "Starters", "Salads", "Breads".
    It turns out that a "Few" sections turned out to be over a dozen, meaning over a hundred different pieces of food. When he told me that his menu was larger than average I thought about having the button "Order Online" on the navigation bar with a drop down menu leading to different pages, each contain one section of the menu. Of course, I can't do that when there are over 12 different sections because then it looks completely stupid.
    I now need some way to actually display it on the webpage. So I decided on like a mini navigation bar within the page itself located to the left of the main body. This navigation bar (Vertical and taking up less than a fifth of the screen) should control what is shown on the right side.
    The page itself shouldn't have to reload, rather only the small section on the right.
    Thanks for the help guys.
    Humm you mention responisve. How do you propose to allocate room for these menus on small screen if you think it looks stupid on a large screen. Fair enough it looks like you have decided to have a vertcial menu to the left of the page - where are you going to put that on a small screen?
    Also I'm a bit concerned about the term 'filtering content on a page'. You may or may not be using th incorrect terminology heer which confuses people into thinking youre using a database to store the products?
    I read it as though youre just going to have a menu list down the left side of your page ie Starters, Mains, Desserts etc then you are just going to build a flat pages containing the products for each menu category and want to bring this page into the box on the right hand side of your main page onClick, but maybe not?

  • How to generate protocol independent content by the servlet?

    Hi All,
    How to generate protocol independent content by the servlet?
    Please give some tips..

    Dear All,
    Can anybody explain it with code..Protocol Independent ..
    Not Http Protocol..You can take any of other protocols ...
    Whether I have to use GenericServlet ? If so, then How?Please explain with code?
    Thanks..

  • TDMS List Contents returns groups for previously opened file

    I get a directory listing of TDMS files, then loop through file by file, using TDMS List Contents to retreive the groups found in the particulare file.  I open each file, list its contents, and close it before opening and listing the next file.
    If a file has no groups, TDMS List Contents returns the group list from the previous file.
    How can I prevent this behavior?

    Unfortunately, the original VIs were developed on a Classified system, so I can't include them here.  However, I've created similar VIs that demonstrate the equivalent problem.
    Run the 'create files' VI to generate appropriate TDMS files, and the 'list contents' VI to demonstrate the issue.
    Note that these VI's were created in LabVIEW 9 SP1 (Version 9.0.1 32-bit).
    Thanks for taking a look it this!!
    Attachments:
    TDMS Issue Create Files.vi ‏18 KB
    TDMS Issue List Contents.vi ‏13 KB

  • Filtering Content in Verity

    Hi Everyone,
    We are implementing the Verity search feature on our site for the first time and have a few questions.
    Currently, we have created one collection that targets the Web root directory.  Is it possible to target specific directories within this folder using a single collection?  There are directories such as 'includes', 'cfc', etc...that we do not want appearing within the search results.
    We have protected documents that are stored outside of the Web root (on a separate drive partition) that we would like to have searchable.  It appears that we would need to create another collection. That being the case, is it possible to have more than one collection searchable within a single cfsearch?
    One of the attribtues that can be returned in the search results is 'title'.  Our site uses a custom tag page wrapper where we pass in the page title.  Is it possible to use this custom tag attribute to generate the title of the document in the search result?  If not, what are some suggestions for this?
    Thank you in advance

    Hi Soren,
    When a user logs onto the portal, they will see only the content that refers to their
    operation(s).
    Control over the display of content for any user will be provided by two means;
    1. security
    2.filter criteria.
    Security will be provided via the Access Control Lists (ACLs) for Knowledge Management (KM) in the SAP Enterprise Portal. 
    Custom filtering logic  required to write the code to provide read-only display for relevant content based on the content category.
    So the criteria  or properties to be added to the KM document when the authors upload the content. The custom filter will then look at the attributes of the user in SAP Backend  and determine which documents will be displayed at runtime.
    The second option would be : Simply, taxonomies are alternate, logical navigation to folders which contain links to the physical content.
    Please refer the prakash blog If you would like to develop a custom filter.
    Krishna

  • Filtering contents of JComboBox using a Renderer

    Hi all,
    I'm writing a Swing panel that needs to display two combo boxes (themes and sub-themes), where the contents of the sub-theme combo is dependent on the theme selected in the first combo box.
    The subtheme combobox model is initialized with ALL the subthemes that can be displayed and my idea was to filter the subthemes for the selected theme within the getListCellRendererComponent() of my subtheme combo renderer.
    The problem I'm having is that the renderer getListCellRendererComponent() method is called for all elements in the subtheme combobox only once, the first time the combo box is displayed. When I update the selected Theme and try to select a SubTheme, the getListCellRendererComponent() method appears to be only called for the set of SubThemes that are being displayed within the scroll area of the combo.
    Is there a way to indicate that the getListCellRendererComponent() should be called for ALL elements in the combo, instead of just those that displayed within the viewable scroll area?
    Or should I not be attemping to perform this filtering in the renderer class?
    Thanks in advance!
    public class SubThemeListCellRenderer extends BasicComboBoxRenderer
                          implements  ItemListener
         private Theme selectedTheme = null;
         private JLabel voidLabel = new JLabel();
         public SubTemaListCellRenderer(Theme theme)
              this.theme = theme;
         public Component getListCellRendererComponent(JList list, Object value,
                   int index, boolean isSelected, boolean cellHasFocus)
              SubTheme subTheme = (SubTheme) value;
                    // Only display subthemes associated with the selected Theme
                    if ( subTheme  != null && selectedTheme != null && subTheme.getCodigoTema() == selectedTheme.getCodigo() )
                       return super.getListCellRendererComponent(list, subTheme.getDescription(), index, isSelected,cellHasFocus);
                    else
                       return voidLabel;
          * (non-Javadoc)
          * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
         public void itemStateChanged(ItemEvent e)
              Object source = e.getSource();
              if (source instanceof JComboBox)
                   Object selectedTheme = ((JComboBox) source).getSelectedItem();
                   if (selectedTheme instanceof Theme)
                        this.theme = (Theme) selectedTheme;
         }

    Thanks for your response. Actually, before I had the idea of using the renderer, I updated the combo box by doing exactly what you suggested. It worked fine, however I was recommended to move this functionality to the renderer!
    After two days of struggling with this, I've reached the conclusion that this operation should not be performed in the renderer and instead by updating the underlying ComboBoxModel (removing and inserting the items as necessary).

  • Filtering content in KM folders

    Hi.
    Is it possible to filter content in a KM folder using properties as filter criteria?
    Example:
    I have a number of files in a folder. In one layout set i want to see all documents with property X = 1. In another layout set I want to see other documents with property Y = 2. Is this possible and how?
    Thanks in advance.
    BR
    Søren Bessermann

    Hi Soren,
    When a user logs onto the portal, they will see only the content that refers to their
    operation(s).
    Control over the display of content for any user will be provided by two means;
    1. security
    2.filter criteria.
    Security will be provided via the Access Control Lists (ACLs) for Knowledge Management (KM) in the SAP Enterprise Portal. 
    Custom filtering logic  required to write the code to provide read-only display for relevant content based on the content category.
    So the criteria  or properties to be added to the KM document when the authors upload the content. The custom filter will then look at the attributes of the user in SAP Backend  and determine which documents will be displayed at runtime.
    The second option would be : Simply, taxonomies are alternate, logical navigation to folders which contain links to the physical content.
    Please refer the prakash blog If you would like to develop a custom filter.
    Krishna

  • HttpServletRequest content returning to the browser

    I�m implementing a test servlet, which receives a file upload POST...
    I�m trying to get the string received by the HttpServletRequest and then return it as html to the browser.. I need it to watch the post structure my form is sending to the servlet.....
    any tip?
    I�m a novice in servlet technologies

    I got it:
    BufferedReader br = requisicao.getReader();
    String j = br.readLine();
    while(j != null)
         System.out.println(j);
         j = br.readLine();
    br.close();

  • Filtering content in Bridge using more than one keyword.

    Hi,
    I have thousands of images in one master folder on an external hard-drive. I have applied many keywords to the images but I cannot find a way to filter the images any more than one layer deep. Some images have more than one keyword applied and I would like to be able to exclude one of those keywords from the search to reveal the other.
    For example, I have 300 images that all have the keyword "Arroway" (Arroway is the content provider FYI). 150 of these images have the keyword "Concrete" assigned, the other 150 have "wood" applied. I would like to be able to sort by Arroway, and then by material type. Is this possible?

    Not by filtering but doable with  Edit  > Find
    Or you could make a Smart Collection.

  • Filtering Content in Assignment Blocks

    In CRM 7.0 we are marking Accounts and Contacts for Archiving (the Archive Flag). We want to filter these out of the possible choices in the Interaction Center, Account Identification screen, and in the Assignment Blocks for Account or Contact. Is there a way to filter out those Accounts and Contacts which have been flagged for Archiving from subsequent CRM screens or Assignment Blocks? How would we do this? Is it perhaps by blocking them in the Authorizations area?
    Thanks, Bryan Johnson
    Lastar, Inc.

    Hi Soren,
    When a user logs onto the portal, they will see only the content that refers to their
    operation(s).
    Control over the display of content for any user will be provided by two means;
    1. security
    2.filter criteria.
    Security will be provided via the Access Control Lists (ACLs) for Knowledge Management (KM) in the SAP Enterprise Portal. 
    Custom filtering logic  required to write the code to provide read-only display for relevant content based on the content category.
    So the criteria  or properties to be added to the KM document when the authors upload the content. The custom filter will then look at the attributes of the user in SAP Backend  and determine which documents will be displayed at runtime.
    The second option would be : Simply, taxonomies are alternate, logical navigation to folders which contain links to the physical content.
    Please refer the prakash blog If you would like to develop a custom filter.
    Krishna

  • Incomplete HTML Returned by Servlet

    I'm having a problem where incomplete HTML is being returned to the client (browser) by my servlet. This is (obviously) causing problems with the HTML page creation at the browser.
    To create the HTML, I'm getting a handle to the output stream, creating the HTML code using a series of println commands, then closing the output stream:
    PrintWriter out = response.getWriter();
    out.println("<HTML><HEAD>");
    out.close();
    However, the web page is rarely completely sent (it's pretty big, but no bigger than some I've seen) before the browser (tries) to display it.
    The servlet works perfectly when I'm running it locally. As soon as I try to run it off a shared server (or from an ISP), the problems arise.
    I'm considering resetting the buffer size with a HttpServletResponse.setBufferSize(), but I'm not sure if that's the problem.
    Any ideas?
    Mark

    I've also seen similar behavior when forwarding
    requests between servers where one server supported
    "chunked" transfer encoding, and the other one didn't.
    The first server would sent the response stream to the
    second server in pieces, but the second server would
    just send along only the first chunk to the client.That sounds possible (certainly describes what I'm seeing), except that I'm getting/putting and responding to/from the same (single) servlet.
    I'm not familiar with "chunked" transfer encoding...is that some sort of HTML header setting?

  • How to build a KQL that Filters content based on a NULL value

    Hi,
    A rather simple question. How to I configure the Content Search Webpart to return all pages where a specific column do not have a value? Or has a value?
    I've bound a column to the Location Term in UPS for a content type and would like to find pages where nothing is selected in that column. Read the
    http://technet.microsoft.com/en-us/library/jj683123.aspx but cant see any possibilities to do that? Have I overlooked something?
    Thank you

    Hi,
    You cannot easily use the "search this site" scope, as it adds a u= parameter which limits results to that url only.
    So, you can still create a result source which brings in items from either the catalog or the current site. Copy the settings in the catalog and add an OR statement like:
    ... OR path:{Site.URL}
    That should include the catalog items as well as items in the current site. You would then have to rewire the search box to go to a search page which uses your new result source. If that search page is on another URL than the web itself, you have to use
    a variation of the same, but you cannot use the Site.URL query variable. I'll clue you into it if that is needed.
    Thanks,
    Mikael
    Search Enthusiast - SharePoint MVP/MCT/MCPD - If you find an answer useful, please up-vote it.
    http://techmikael.blogspot.com/
    Author of Working with FAST Search Server 2010 for SharePoint

  • How to share My Folders  and My filters contents to other User ?

    Hi All ,
    How can we share the contents of My folders and My filters to other user?
    The scenario is like below -
    Let's say i have 2 users , Administrator and XYZ . Both the users belong to Administrators Group.
    The user Administrator creates some request and filters and save it in My folders and My filters respectively. Now Administrator wants to share these saved requests and filters to user XYZ.
    How can Administrator share it with user XYZ?
    Do i need to put all the saved requests and filters in shared folders to share with user XYZ ?
    Or is there any way to share these contents without putting in the shared folders?
    -- Ashish

    Copy those reports into a shared folder. That's the whole point of having "My" and "Shared" folders :)
    If you have a lot of objects that need to be copied, consider using the Catalog Manager tool where you can manipulate multiple objects at the same time.

  • Html filtering content length issue

    I am using the Filter type="filter-hhtml" to tets stripping out EMBED and OBJECT tags from html pages. It is working fine but when the resulting page is loaded the browser (konquorer in this instance) reports a content length mismatch and shows an error message. The new page is shown. When I try and view the html source I get the same error and never get to see the source. When I try under Firefox and IE it works fine. I was just wondering if it was possible (or even necessary) to change the content-length to accurately depict the resulting size of the page after filtering?

    Checkout send-error.So I can place a drective like this (assuming I have a 403.html file in that location):
    Error fn=send-error code=403 path=/opt/sun/webproxyserver/html/errors/403.html
    I assume I place this inside my Object definition for my template ... is that correct? I plan on placing it at the bottom of my template. Does its location in the Object definition matter? I am sorry but the docs are not real clear (at least to me) on hard details so forgive my questions.
    just for clarity is this a proper template definition(I have 3)?NameTrans fn="assign-name" name="BlackList" from="http://.*yahoo.*"
    NameTrans fn="assign-name" name="WhiteList-level1" from=".*://64\.215\.169\.*/.*|.*://.*gblx.net/.*"
    NameTrans fn="assign-name" name="WhiteList-default" from=".*://.*/.*"
    The one named BlackList is just for testing purposes (which I can't seem to get to work either.
    Isn't the following legal? When I have a template match it should go to this object and execute directives right? It should see and execute the deny-service right? Why is it not?
    <Object name="BlackList">
    Service fn="deny-service"
    Error fn=send-error code=403 path=/opt/sun/webproxyserver/html/errors/403.html
    </Object>
    thanks again
    Doug

Maybe you are looking for

  • HT5225 Will the iCal on my computer no longer store my information?

    After I move to iCloud without all my devices being compatable, will my iCal on my laptop still store my information and function.  Also, as long as I manually plug my iPod in, will it still sync my calendar events?

  • How to mention Email ID in an IVIEW

    Hi Everyone, I have to create a Iview where user enter the name and other information and hit on the submit button a mail has to be sent to admin at the rate xxx.com;(i cannot add the emial id) How can i accomplish this. also I have a Iview under myH

  • Should the bluetooth in an ipad 1 recognise bluetooth from a mac mini (snow leopard) or iphone4?

    Hello, i have an ipad1 64gb 3g which obviously has bluetooth.  When searching devices it has never recognised another device, particularly the mac mini and iphone.  Bluetooth is switched on.  I would like to eventually be able to wirelessly sync cale

  • Can't find Microphone in Audio Hardware

    Hi guys, I'm desperate to record a voiceover for a film and am struggling to find my mic + preamp in my audio hardware list. I am using an M-Audio Nova plugged into a CME Mtraix X preamp (as the mic needs phantom power) and can't seem to find a tutor

  • CRM Update issue

    Hi Friends, I am trying to update a contract date from ECC to CRM via proxy, once I update the date I need to lock the contract in CRM for no further changes, but I am not able to achieve this because I think the contract is getting locked before it