HttpServletRequest Object Question?

I need to manipulate the Header (specifically the Authorization) of an Http request made to a servlet. I would assume that the header is encapsulated in the HttpServletRequest object sent to the server, but I don't seem to have any way of accessing it.
Any suggestions, advice?
Thanks

The header is included in the HttpServletRequest instance, but you might be misunderstanding that interface. HttpServletRequest instances are only meant to wrap a client request to some server- not the server's response. Thus, you can retrieve values from the request, but you can not set them (not through HttpServletRequest), because the instance only wraps a client's request. To set a header value, use HttpServletResponse:
response.setHeader("Refresh", "15");
... you can get a Header value from the request by,
request.getHeader("Refresh");

Similar Messages

  • Using HttpServletRequest object to share variables between static methods.

    Does anyone know of the overhead/performance implications of using the HttpServletRequest object to share variables between a static method and the calling code?
    First, let me explain why I am doing it.
    I have some pagination code that I would like to share across multiple servlets. So I pulled the pagination code out, and created a static method that these servlets could all use for their pagination.
    public class Pagination {
         public static void setPagination (HttpServletRequest request, Config conf, int totalRows) {
              int page = 0;
              if (request.getParameter("page") != null) {
                   page = new Integer(request.getParameter("page")).intValue();
              int articlesPerPage = conf.getArticlesPerPage();
              int pageBoundary = conf.getPageBoundary();
                int numOfPages = totalRows / articlesPerPage;  
                // Checks if the page variable is empty (not set)
                if (page == 0 || (page > numOfPages && (totalRows % articlesPerPage) == 0 && page < numOfPages + 1)) {    
                 page = 1;  // If it is empty, we're on page 1
              // Ex: (2 * 25) - 25 = 25 <- data starts at 25
             int startRow = page * articlesPerPage - (articlesPerPage);
             int endRow = startRow + (articlesPerPage);           
             // Set array of page numbers.
             int minDisplayPage = page - pageBoundary;
             if (minDisplayPage < 1) {
                  minDisplayPage = 1;     
             int maxDisplayPage = page + pageBoundary;
             if (maxDisplayPage > numOfPages) {
                  maxDisplayPage = numOfPages;     
             int arraySize = (maxDisplayPage - minDisplayPage) + 1;
             // Check if there is a remainder page (partially filled page).
             if ((totalRows % articlesPerPage) != 0) arraySize++;
             // Set array to correct size.
             int[] pages = new int[arraySize];
             // Fill the array.
             for (int i = 1; i <= pages.length; i++) {
                  pages[i - 1] = i;
             // Set pageNext and pagePrev variables.
             if (page != 1) {
                  int pagePrev = page - 1;
                  request.setAttribute("pagePrev", pagePrev);
             if ((totalRows - (articlesPerPage * page)) > 0) {
                 int pageNext = page + 1;
                 request.setAttribute("pageNext", pageNext);
             // These will be used by calling code for SQL query.
             request.setAttribute("startRow", startRow);
             request.setAttribute("endRow", endRow);
             // These will be used in JSP page.
             request.setAttribute("totalRows", totalRows);
             request.setAttribute("numOfPages", numOfPages);
             request.setAttribute("page", page);
             request.setAttribute("pages", pages);          
    }I need two parameters from this method (startrow and endrow) so I can perform my SQL queries. Since this is a multithreaded app, I do not want to use class variables that I will later retrieve through methods.
    So my solution was to just set the two parameters in the request and grab them later with the calling code like this:
    // Set pagination
    Pagination.setPagination(request, conf, tl.getTotalRows());
    // Grab variables set into request by static method
    int startRow = new Integer(request.getAttribute("startRow").toString());
    int endRow = new Integer(request.getAttribute("endRow").toString());
    // Use startRow and endRow for SQL query below...Does anyone see any problem with this from a resource/performance standpoint? Any idea on what the overhead is in using the HttpServletRequest object like this to pass variables around?
    Thanks for any thoughts.

    You could either
    - create instance vars in both controllers and set them accordingly to point to the same object (from the App Delegate) OR
    - create an instance variable on the App Delegate and access it from within the view controllers
    Hope this helps!

  • How to get the HttpServletRequest object in a jsp

    Hi,
    I am a little confused here. Am trying to use the HttpServletRequest object in my jsp. I have set up just a simple test page jsp. How can i use the HttpServletRequest object to get some information about the request for example using the method getPathInfo(). I know i can do this in a servlet and pass the value as a parameter in a doGet method. But how do i do it in a jsp. Can it be done..?
    Pls help
    Thankyou

    The request object is already created for you in JSP, as are many other things
    request - the HttpServletRequest object
    response - the HttpServletResponse object
    session - the HttpSession object
    application - the ServletContext object
    out - the JspWriter object (like PrintWriter)
    So you just use them...
    <%
    String asdf = request.getParameter("asdf");
    %>

  • Can I get the HttpServletRequest object in my custom auth providers?

    Hello -
    If I write a custom authentication or identity assertion provider, is there a way to get the HttpServletRequest object of the user's request?
    Thanks,
    -- Scott

    You can do it from your identity asserter in the following way!
    public CallbackHandler assertIdentity(String type, Object token, ContextHandler context) throws IdentityAssertionException
    Object requestValue = context.getValue("com.bea.contextelement.servlet.HttpServletRequest");
    HttpServletRequest request = (HttpServletRequest) requestValue;
    -Faisal
    http://www.weblogic-wonders.com

  • Wana XI objective questions

    Hi all,
    any body wants XI certification objective questions I have some that please contact me on personal mail id
    [removed by moderator]
    I will forward that doc.
    Thanks & Regards,
    Ashok Kumar.M
    Selling certification questions is illegal and point mongering for them is not a respected community activity - [by moderator]

    Hi Ashok,
    SAP SDN is a devloper forum where Professional Developers all around the world discuss their issues and share knowledge among themselves for any support.
    Please dont post this type of questions on this forum in near future for any personal gains.
    Thanks
    Prasad

  • Getting the Client Certificate out of the HttpServletRequest object

    I have an interesting issue with weblogic 5.1 SP6 and getting/obtaining Client
    Certificates.
    The issue is that the Client Certificate is not always in the HttpServletRequest
    object depending on how the weblogic.properties are set. Here is my code to get
    the Certificates.
    // get the cert chain from the request
    Object obj=request.getAttributs("javax.net.ssl.peer_certificates");
    if (obj instanceof weblogic.security.X509[]) {                          
    weblogic.security.X509[] wlogicCert = (weblogic.security.X509[]) obj;
                                            try {
                                            iaik.x509.X509Certificate iaikClientCert =
         new iaik.x509.X509Certificate(wlogicCert[0].getBytes());
         clientSDN = aiaikClientCert.getSubjectDN().getName();
         clientCert = (Certificate)iaikClientCert;
    The only time the certificate is present in the Request Object is when the following
    weblogic.properties are set:
    weblogic.security.enforceClientCert=true
    weblogic.security.clientRootCA=CARoot.pem
    If the properties are set to to this: no Certificate can be received from the
    Request object.
    weblogic.security.enforceClientCert=false
    #weblogic.security.clientRootCA=CARoot.pem
    Is there a way to have Weblogic always receive/get a Client Certificate if one
    is provided by the client, but not have weblogic do any validation of the certificate?
    Any help would be appreciated!
    Gary

    ok i see.
    although it should be able to get the underlying
    outputStream handle since i have initialized
    (associated) it on the previous line.
    ThanksWell, you might be able to get the underlying stream. Look at the API docs. If there's a method there to do it, then you can. If not, then you can't.
    If you can do it, then you have to look at the API docs for FileOutputStream and see if it lets you get the associated File or path. If such a method exists, then you can get it. If not, then you can't.
    Even if both methods exist and you can utimately get the file, do you understand why this is not the same as "getting the file associated with a PrintStream"?

  • Objective question book for certification

    Hi,
    I was preparing for my first level certification CLAD. I wanted to know if there is any book on the objective questions . I have already cleared the fundamental test at ni.com. I am looking for more practise.
    Anyone who has given the test or plan to give one, please post some ways of preparing for the exam.
    Also how hard it is ?
    Any special tips for 2006 exam?
    Any help would be greatly appreciated.
    I am preparing for the exam by reading basic I and Basic II books.
    I have given couple of fundamental tests on the NI website.
    Also I keep reading and answering  NI discussion posts to check on my knowledge about Labview.
    Any other material that would be helpful in clearing the exam.
    Also according to certification FAQs the passing percentage is 70% whereas the fundamental test results will declare you Pass only when you score more than 80 %.
    What is actually the passing percentage for the exam?
    Regards
    CLAD
    Using Labview 5.1,6.1,7.1.8.0

    Passing the test myself you are required by NI not to disclose any information so where do I start?  If you have been using LabVIEW for at least a year you should be fine.  The test is constantly changing so even if I were to tell you what to study it may be all different.  I guess the best advice would be able to inspect code without running it and know what LabVIEW result will be.  If you are comfortable with loops and shift registers and understand what the result of the code wold be then you should do OK.  I know the questions was what books would help the most.  I just looked at the LabVIEW manual and managed to do fine.  Another tip would to be study the things that you typically don't use or how it is implemented.  A book will help you to a point but you need to be comfortable with LabVIEW and its wide functionality.
    Does this help?
    Matthew Fitzsimons
    Certified LabVIEW Architect
    LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison

  • Is it necessary to synchronize HttpServletRequest object

    Is it necessary to synchronize HttpServletRequest object .
    Justify your answer
    With regards
    Aruanbh Dash

    i'd say no, because it's supposed to be generated and processed by a single thread of the servlet engine
    after that, nobody will arrest you if you torture a request with multithreading

  • How do I get the client IP Address from the HTTPServletRequest object

    Hi ppl,
    How do I get the IP address of the client machine from the HTTPServletRequest object?
    Thnx in advance,
    Manoj

    Take a look at: http://java.sun.com/products/servlet/2.2/javadoc/index.html and check for the ServletRequest Interface.
    Be aware also if your web server is using proxy, proxyReverse and so because you could end getting the servers' IP and not client one.

  • Question on HttpServletRequest object

    If I have a request object (say r), am I able to remove a parameter from that object and replace it in a servet?
    I am trying to take a double value from a form (not a problem) and pass it into a servlet. What I want to do is in the servlet, run some update code on the value, put it back into the request object, and then do the doPost method on it. Is that possible?
    Is it just as simple as r.removeAttribute(name) and a r.setAttribute(name,obj)? Or is it a little more complex than that?
    - Josh

    Parameters and Attributes are completely different things.
    Request parameters come from the HTTP Request. They can only be strings. Request Parameters are not normally editable.
    Request attributes are java objects. Its basically a useful space to store your java beans in.
    What I want to do is in the servlet, run some update code on the value, put it back into the request object, and then do the doPost method on it. Is that possible?What do you expect to trigger this "update" code? Isn't the doPost method the first entry point into the servlet? If you want to run something BEFORE the doPost of the servlet you might look at using a servlet filter
    Take a look at [This post|http://forums.sun.com/thread.jspa?threadID=682565] which discusses "editing" request parameters.
    Hope this helps,
    evnafets

  • ADF View objects question

    Hello,
    I created a view object (which bases on an entity object) that I'd like to use for searching for records in a table called "CARS". Cars will be searched by names. I also have a JSP page for adding cars (administration functionality).
    The situation is as follows:
    1. I go to the page for adding cars and click "Submit" (which only submits data without committing to the database).
    2. Then I have validation errors (which is ok because some fields are mandatory).
    3. I search for cars by name.
    The funny part is that if I search for cars with given names, I get those cars AND I get the empty row with this new car I'd tried to add just a moment ago. It's definitely not yet in the database and the name of this car is not set (so it shouldn't match with the name I'm searching for).
    My question is: why is it happening and what should I do to get the rows created but not yet committed not appear in the search results?
    I tried to use clearCache() method of ViewObjectImpl but the result is still the same.
    Please help because I desperately need this for my diploma project.
    Thanks,
    Anna

    I run: "java -Djbo.viewlink.consistent=false -jar oc4j.jar" and I still get new rows. I'm using OC4J 10g (9.0.4.0.0) standalone that comes with JDeveloper 10g (9.0.5.2) on Linux.
    And about that Create pages: I mean I click on a link "New something" 3 times (for example). I don't use the browser back button because I have my menu on each page. In this case I'm just curious if it's possible to somehow "overwrite" previous "new" rows with the most recent one.
    I thought I would need that but now I know I need something else.
    Imagine such a situation:
    1. A user wants to create a new row or update an existing one.
    2. They start filling the form and submit it (in my case it's committing at the same time)
    3. During validation it turns out that some required values are missing so the user has to enter them.
    4. At this point the user leaves the input form and decides to add or update a different row.
    5. The user enters all the required values and this time validation would succeed. However, because of points 2. and 3. it does not.
    Now my question is: how can I make ADF somehow "forget" about the row inserted/updated in point 2. I know that ADF validates all new/changed rows at a time. But I would like to change that behavior so that it would validate only the row changed/created most recently.
    Thanks,
    Anna

  • Oracle Apps Objective question and answers

    Hi all,
    We need Oracle Apps(DBA, Tech & Funct) objective type questions with answer.
    Can you any one help to find the questions. Even if they are any links, dumps, doc please post them.
    Thanks,
    Ramaraju.

    HI Ramaraju,
    You can search for FAQ related to topics like adpatch, cloning etc etc
    Google should be your friend
    for DBA check this out its the best book
    Cracking the Oracle Apps DBA Interview: 325 Frequently Asked Questions  – June 12, 2009
    by Joyjeet Banerjee (Author)
    for technical
    http://oracleappstech12.blogspot.com/2012/08/oracle-apps-technical-interview.html
    Oracle Apps Technical Interview Questions, Answers for Freshers and Experienced asked in Job Interviews
    http://oracleapps4u.blogspot.com/2011/07/oracle-apps-interview-questions-and.html
    etc etc
    well for functional it depends on the module
    I'm not aware  of  any dump which covers all (administration, technical and functional )  of them so you need to Google as per the module for functional
    ApPsMaStI
    sharing is Caring

  • ABAP Objects Questions

    Hello Everyone,
    I hope someone could answer the following questions:
    Please look at the below ABAP code
    data: zVar(30)                type c value 'ZTEST_CLASS',
            methodName(30)    type c value 'Test_Method'.
    Question # 1:  Can I define the objVar as below or is there anyother way to accomplish this?
    data:  objVar  TYPE REF TO  zVar.  (Please note that zVar is the variable that contains the name of the 
                                                           class)
    Question # 2: Can I create the object objVar from the above question as below?
    CREATE OBJECT objVar.
    Question # 3: Can I call the method of objVar as below
    CALL METHOD objVar->Test_Method (please note that test method is a variable that contains the name
                                                             of the actual method)
    Thanks in advance.
    Regards

    All these Can be done using Dynamic programming.
    check this
    REPORT  ZTEST_CLASS.
    data: zVar(30) type c value 'ZCL_TEST1',  "<--class name
    methodName(30) type c value 'TEST'.   "<----Method name
    data: obj type ref to object.
    create object obj TYPE (zvar) .
    call method obj->(methodname).
    break-point.

  • CS5 Smart Object Question

    I just migrated from CS4 to CS5 , I have a .psd that has layers with that are photos which contain blending layers inside their original psd's. They were  converted and imported to the main.psd as jpgs. Is there a way to convert each of those layers to a smart object and in my case edit the blended layer which contains a blackborder so I can make the border smaller?
    Or do I need to get the original jpg photo, create a new border and resave as a jpg?
    rd

    I don’t quite follow, but I would assume that one should place the files without the borders and possibly just apply the Layer Style Stroke.
    One can certainly convert a Layer to a Smart Object, but if that Layer has been transformed before that won’t improve image quality and it certainly would not change a flattened layers back to a previous multi-layer-state – but like I said I may be misunderstanding the question.

  • Activex Object Question

    Hi,
    I posted this question by mistake in the LabVIEW/CVI fourms, so I am reposting it here.  I have a question about how LabVIEW "sees" activex controls.  I have a dll, which displays createable objects in the activex menu.  LabVIEW sees the type library name and I can create methods and property nodes.  Now, when I load the same dll into VB 2008, I get the self-registration error, eventhough the dll was manually registered using regsrv32.  What is LabVIEW doing to be able to "see" the activex controls inside the dll?

    Hey shivels,
    The dll you are using is working properly in LabVIEW? It seems like the problem is less with LabVIEW and more with VB2008. It might be more helpful to post your question in a forum for VB2008 to figure out why it is not working. The lowest level code that LabVIEW is using to interface with ActiveX is not information that is really make available.
    Hope this helps.
    -Ben
    WaterlooLabs

Maybe you are looking for

  • How to open a .session file?

    I have a .session file. Basically I had many tabs open and then saved them in a .session file for later use. I now can't open it with the version 26 or even 22. When I open it, it just shows them in text form. Is there a way to open this .session fil

  • Preserve whitespace from longtext, but not overflow div

    I am building a page to display query results where one of the fields is long text with formatting (bullets, etc).  This field holds text that the user can copy and paste, so I want it to display as copied.  I have found that using whitespace=pre on

  • Grid in Oracle Forms

    wil it be possiblt to create a form where we can drag the change the width of the columns in the form. How can this be accomplished?

  • Error in gl account

    I have created a gl account (expense ) and when iam trying to post a document its giving me a weird error as  " Create account xxxxxxx for 3/11/2008 as a costelement in controlling area ".

  • Does Mac OS 10.6.2 disable Flash Player?

    I cannot play a .swf file under OS 10.6.2 using the Flash Player.plugin ver. 10.0.32.18 but can play the same file under OS 10.5.6 using Flash Player.plugin ver. 9.0.151. I can also play it under OS 10.6.1 and under 10.4.11. Is this an OS issue or an