Accessing parameters from request header in init()

Hello
How can I access parameters passed on the client request header like
http://localhost:8080/servlet/DBServlet?database=mydatabase
from the servlet initialization method ini()
The getInitParameter() only returns parameters defined in the web.xml file (if is this correct).
I would like to use the getParameter() from the request class, how can I do this within init()
Thanks

Greetings,
Hello
How can I access parameters passed on the client
request header like
http://localhost:8080/servlet/DBServlet?database=mydat
base
from the servlet initialization method ini()You can not. As you pointed out, the init() method is for servlet initialization - it is called by the container to allow the servlet to prepare to receive requests, which are then passed to the service() method.
The getInitParameter() only returns parameters defined
in the web.xml file (if is this correct). That is correct - parameters can be defined in the deployment descriptor in either the <servlet> level (passed to the servlet in ServletConfig), or the <webapp> level (passed to the entire webapp in ServletContext).
I would like to use the getParameter() from the
request class, how can I do this within init()Again, you can not - there simply is not any client communication during initialization.
ThanksRegards,
Tony "Vee Schade" Cook

Similar Messages

  • Retriving only hidden parameters from request.getParameter

    Hi,
    I want to retrive only the hidden parameters from previous JSP page into current JSP page. The problem here is that my hidden parameters in privious page are dynamically generated (parameter names are decided based on values retrived from the database) and I cannot retrive them using "request.getParameter(<parametername>)"
    Can I find the parameter type (i.e. text box, text area, checkbox, radio or hidden) from the request.getParameter() or request.getParameterNames() methods? or is there any other way to find it.
    Thanks in advance for any help

    You can use the getParameterNames() or getParameterMap() methods from javax.servlet.ServletRequest to get all the parameters in the request. Even if they're dynamically generated, and you don't know the names in advance, these methods will ferret them out.
    getParameterMap() returns name String, values String [] pairs, so you'll have to work with String arrays to get the input out. It's got to be that way to accomodate checkboxes and other HTML form elements that can send more than one value for a given name.
    I prefer getParameterMap, because I don't like using Enumerations as much. - MOD

  • How to read parameters from request object

    We want to read parameters from GET request
    but whenever we are calling GET_URI_PARAMETER from the REQUEST we don't see any results
    url is like
    http://coevi116.wdf.sap.corp:8000/sap(bD1lbiZjPTEwMA==)/bc/bsp/sap/z_test_json/jsontest.htm?PARAM=ABC
    But reading PARAM is not givng value of ABC
    onCreate and onRequest wherever we put the code it is not reading the value
    Can anyone please help and share some expert opinion

    in jsontest.htm page create a page attribute named "PARAM" with auto check box checked and check in oninitialization, this will carry the value passed to param from url.

  • How to access parameters from an object stored in a shopping-cart vector?

    Hello;
    I am writing some code that will be part of a website that will have the
    ability to allow customers to place items into a shopping cart and then
    purchase them.
    The way that the shopping cart works is that a products page is displayed on the website that has 'add' buttons on it next to each product on the page.
    When the customer clicks the 'add' button next to a particular product to purchase it, the code performs a query of a products database table for the numeric product id linked to the 'add' button they clicked.
    When the product id is found, the query then loads the
    product information for it from the DB table columns into the shopping cart
    Vector as an object in the form of a result set string. This object contains
    the parameters that define the product, i.e. product_id, product_quantity,
    date_ordered, ship_status and so on.
    In the code, when the customer is done shopping and clicks on a button
    labelled 'place order', I want the code to access the shopping cart Vector
    and extract each item object from the cart. I then want the code to be able
    to get from each item object, the parameters that make up each item as
    described above and take the values stored in each of the parameters and
    store them in variables. Finally I want to take those variables and write
    them to an orders DB table in the proper columns via a query.
    I have tried researching information on Vectors to see if I could find out a way to do this but the little information that I located did not give me a clear idea
    of how to go about writing the code, it only seemed to suggest a vague,
    rough idea as to how it might be done. I am relatively new to Java
    programming and so don't have any experience working with Vectors.
    I have enclosed the code below that shows how the items are being stored in the shopping cart Vector. Can anybody tell me how I could go about writing the code that will extract the items from the shopping cart as described above in a servlet? Any assistance you can give me will be greatly appreciated.
    Thank you!
    String productID = request.getParameter("productID");
    String qty = request.getParameter("qty");
    Vector cartlist = new Vector();
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    java.sql.Connection conn = java.sql.DriverManager.getConnection("jdbc:odbc:website", "", "");
    java.sql.Statement st = conn.createStatement();
    String query = "SELECT productID, productName, productCategory,
    productPrice from Products WHERE productID ='" + productID + "'";
    java.sql.ResultSet rs = st.executeQuery(query);
    while(rs.next()){
    cartlist.addElement(rs.getString("productID") + " " +
    rs.getString("productName") + " " +
    rs.getString("productCategory") + " " +
    rs.getString("productPrice") + " " + qty);
    } catch(SQLException sqlex){
    } catch(Exception e){
    }

    //Try Changing your code this way.
    String productID = request.getParameter("productID");
    String qty = request.getParameter("qty");
    Vector cartlist = new Vector();
    try
         Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
         java.sql.Connection conn = java.sql.DriverManager.getConnection("jdbc:odbc:website", "", "");
         java.sql.Statement st = conn.createStatement();
         String query = "SELECT productID, productName, productCategory, productPrice from Products WHERE productID ='" + productID + "'";
         java.sql.ResultSet rs = st.executeQuery(query);
         while(rs.next())
              String productID = rs.getString("productID");
              String productName = rs.getString("productName");
              String productCategory = rs.getString("productCategory");
              String productPrice = rs.getString("productPrice");
              String productID = rs.getString("productID");
              cartlist.addElement(new AddCardElement(productID, productName, productCategory, productPrice, productID, qty));
              //class AddCardElement should be there in your application
    catch(SQLException sqlex)
    catch(Exception e)
    //you have to add a new class AddCardElement like this
    class AddCardElement
        public String m_productID;
         public String m_productName;
         public String m_productCategory;
         public String m_productPrice;
         public String m_productID;
        public GenerateLocationData(String productID, String productName, String productCategory, String productPrice, String productID, String qty)
            m_productID = productID;
              m_productName = productName;
              m_productCategory = productCategory;
              m_productPrice = productPrice;
              m_productID = productID;
    }//-Achyuth B

  • Parameters from HTTP header and HTTP parameter

    All,
    I am very new to APEX. Our new application needs to get two values, one from a HTTP header and the second from a HTTP parameter. I do not know how to do this. Is there an existing function like GET_HTTP_HEADER.val?
    Thanks for any help.
    Fred

    user7183753 wrote:
    Andy,
    Thanks for the quick reply. The OWA_UTIL will give me static information.owa_util.get_cgi_env should be able to get any http header information that you require.
    You can modify the dads.conf file to allow non-standard HTTP headers to be passed through, you add a PlsqlCGIEnvironmentList entry e.g.
    PlsqlCGIEnvironmentList AuthorizedUser
    If your users access an external URL to be authenticated and then that external system forwards to you with the new header showing the authenticated user name, you could pick up that 'AuthorizedUser' header as part of your own authentication mechanism.

  • Reading DLL function and parameters from a header file

    Hallo to everyone,
    I am trying to find a cute way

    Hello,
    I think this is what you were asking in another stream.  I don't think there is a way to do that.  For examples of passing data to dlls given the naming convention variation across environments, check out the shipping example named Call DLL.vi, which will open other examples of using call library function nodes with a datatype you specify.
    I hope this helps, and these suggestions are very welcome at our feedback site - click Contact NI at ni.com, and then the word "feedback" in the lower left corner to submit a product suggestion.
    Best Regards,
    JLS
    Best,
    JLS
    Sixclear

  • Initialize managed bean from request parameters

    Hi:
    I thought this topic would be on the FAQ, but I couldn't find it. I am looking for a mean to initialize my managed bean from the query string. There must be something like:
    <h:form initializeBean=""true"" requestParameter=""id_author"" beanProperty=""#{author.id_author}"" action=""#{author.getFromDB}"" >
    </form>
    The url would be something like http://localhost:8080/protoJSF/showAuthor.jsf?id_author=5334
    And the getFromDB method would be something like
      Public void getFromDB()
         Statement stmt = cn.createStatement( ?SELECT * from author where id_author=? + getId_author() );
         ResultSet rs = stmt.executeQuery();
      }The only way I've found to perform something like this is to present a blank author form with a ''load data'' button: after pressing the button the user can see author's data and edit the data if she wants to. This two-step data screening is annoying, to say the least.
    There must be a better way.
    I beg for a pointer on how can I achieve the initializing of a managed bean with dynamic data.
    Regards
    Alberto Gaona

    You just have to read carefully the very fun 289 pages
    specification :-)Or, if 289 pages of JavaServer Faces is too much, you can get almost all of the same information from the JavaServer Pages 2.0 specification, or even the JSP Standard Tag Libraries specification :-).
    More seriously, the standard set of "magic" variable names that JavaServer Faces recognizes is the same as that reognized by the EL implementations in JSP and JSTL. Specifically:
    * applicationScope - Map of servlet context attributes
    * cooke - Map of cookies in this request
    * facesContext - The FacesContext instance for this request
    * header - Map of HTTP headers (max one value per header name)
    * headerValues - Map of HTTP headers (String array of values per header name)
    * initParam - Map of context initialization parameters for this webapp
    * param - Map of request parameters (max one value per parameter name)
    * paramMap - Map of request parameters (String array of values per parameter name)
    * requestScope - Map of request attributes for this request
    * sessionScope - Map of session attributes for this request
    * view - The UIViewRoot component at the base of the component tree for this view
    If you use a simple name other than the ones on this list, JavaServer Faces will search through request attributes, session attributes, and servlet context (application) attributes. If not found, it will then try to use the managed bean facility to create and configure an appropriate bean, and give it back to you.
    For extra fun, you can even create your own VariableResolver that can define additional "magic" variable names known to your application, and delegate to the standard VariableResolver for anything else.
    Craig McClanahan

  • Getting parameters from multipart request

    I'm using org.apache.tomcat.utils.fileupload to parse uploaded files from a multipart form, but unfortunately I can't seem to get normal parameters from such a form with request.getParameter(). Is there a way to use both together?

    You might already have solved your problem, but you may find this MultipartFilter useful too: http://balusc.blogspot.com/2007/11/multipartfilter.html
    It automatically detects multipart/form-data requests and sets the plain vanilla form parameters back in the ParameterMap of the HttpServletRequest and sets the files as attributes of the HttpServletRequest. This way there is no need to worry about the form encoding type inside the servlet.

  • I can no longer access Bejeweled Blitz through my facebook account.  I get the message that says, "your browser sent a request that this server could not understand. Size of a request header field exceeds server limit".  Help please.

    I can no longer access Bejeweled Blitz through facebook.  I get the message, "your browser sent a request that this server could not understand. Size of a request header field exceeds server limit". I can access Bejeweled through FB using my husband's log in so to me that suggests the problem is with my log in. Help please.

    Contact FB or use another browser. 

  • How i can find user locale/language from his/her request header ?

    Hi
    thank you for reading my post
    what is request header field that shows user agent language/locale ?
    is there any http header value that shows user locale/language ?
    if yes , how i can extract it ?
    thanks

    Certainly there is.
    http://www.w3.org/Protocols/HTTP/HTRQ_Headers.html#z12
    The header is "accept-language"
    You can get it via
    request.getHeader("accept-language");
    You can use request.getHeaderNames() to give you an enumeration of all the headers sent by the browser, so you can see them and the values.
    Here is an extract from a test page I use every once in a while that prints out useful information. This bit prints out request headers (using JSTL)
    You can just drop it into a jsp page (don't forget to import the JSTL tag library) and it will show you all the request headers.
    <h3>Headers </h3>
    <table>
    <c:forEach var="h" items="${header}">
      <tr><td><c:out value="${h.key}"/></td><td><c:out value="${h.value}"/></td></tr>
    </c:forEach>
    </table>Cheers,
    evnafets

  • P6WS "WSS header is missing from request. Can't do username token authentication."

    I am getting the error "WSS header is missing from request. Can't do username token authentication." when trying to connect with SOAP and use Token Auth. I can get Cookies to work just fine, but i need to be able to connect to both.
    testWebReference.Login clientLogin = new testWebReference.Login();
    testWebReference.LoginResponse clResponse = new testWebReference.LoginResponse();
    testWebReference.AuthenticationService authClient = new AuthenticationService();
    clientLogin.UserName = paUsername.Text;
    clientLogin.Password = paPassword.Text;
    clientLogin.DatabaseInstanceId = Int32.Parse(paDBI.Text);
    clientLogin.DatabaseInstanceIdSpecified = true;
    AuthenticationService service = new AuthenticationService();
    service.Url = proxy;
    service.SoapVersion = System.Web.Services.Protocols.SoapProtocolVersion.Soap11;
    service.Login(clientLogin);

    I uploaded an example of usertoken on My Oracle Support community.
    TestUserToken.zip
    V/r,
    Gene

  • The adobe CC purchase fails at Confirm Membership phase (getting: No 'Access-Control-Allow-Origin' header is present on the requested resource)

    I'm trying to purchase adobe CC and get this error (in my chrome console) -
    XMLHttpRequest cannot load http://shop.adobe.com/store?Action=QuickBuyCheckoutPlaceRequisition&Env=BASE&Locale=en_GB& SiteID=adbehil. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://shop.adobe.com' is therefore not allowed access.
    how can I purchase adobe cc?
    Thanks,
    Idan

    Please try a different browser, if you are in a company network then you can contact the IT department to get it checked.

  • Reading ESB Request Header elements

    Hi!
    Is it possible to get to SOAP header elements using ehdr:getRequestHeader() function? If yes, can someone provide and example of it? Also, what all are included in the Request Header? Is there a place where I can learn more about Request and other ESB headers?
    More specifically given the following SOAP envelope sent to the routing service:
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Header>
    <wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing">qqqqqqqqqqq</wsa:MessageID>
    </soapenv:Header>
    <soapenv:Body>
    <ns1:Response xmlns:ns1="GeneralResponse">
    <ns1:KeyData>af</ns1:KeyData>
    </ns1:Response>
    </soapenv:Body>
    </soapenv:Envelope>
    How can I read the value of wsa:MessageID? (Please note that we are only using the element from WS-Addressing and not WS-Addressing itself).
    Thank you.

    The only header I get is sap-ep-version, but I am referencing my WD application via iView.
    When I access my WD app via URL, then it doesn't have any HTTP headers. 
    I can pass in URL parameters, which is picked up as HTTP headers.  For security reasons, I would rather not send information as URL parameters.
    I am guessing the code above is for URL parameters.  Is there an option/configuration I am missing here?

  • Help with getting values from request. Very Strange!!

    Hello,
    My very strange problem is the following.
    I have created three dynamic list boxes. When the user select
    the first list box, the second becomes populated with stuff
    from a database. The third becomes populated when the second
    is selected. Now, I have used hidden values in order for
    me to get the selected value from the first listbox. The
    following code is my first listbox:
    <SELECT NAME="resources" onChange="document.hiddenform.hiddenObject.value = this.option [this.selectedIndex].value; document.hiddenform.submit();">
    <OPTION VALUE =""> Resource</OPTION>
    <OPTION VALUE ="soil"> Soil </OPTION>
    <OPTION VALUE ="water"> Water </OPTION>
    <OPTION VALUE ="air"> Air </OPTION>
    <OPTION VALUE ="plants"> Plants </OPTION>
    <OPTION VALUE ="animals"> Animals </OPTION>
    </SELECT>
    I use the getRequest method to get the value of hiddenObject.
    At this time I am able to get the value of hiddenObject to populate
    the second list box.
    But, when the user selects an item from the second list box
    and the second form is also submitted,
    I lose the value of hiddenObject. Why is this??
    The code to populate my second listbox is the following:
    <SELECT NAME ="res_categories" onChange="document.hiddenform2.hiddenObject2.value = this.options[this.selectedIndex].value; document.hiddenform2.submit(); ">
    <OPTION VALUE ="" SELECTED> Category</OPTION>
    Here I access a result set to populate the list box.
    Please help!!

    Form parameters are request-scoped, hence the request.getParameter("hiddenObject"); call after the submission of the second form returns a null value because the hiddenObject parameter does not exist within the second request.
    A solution would be to add a hiddenObject field to your second form and alter the onChange event for res_categories to read
    document.hiddenform2.hiddenObject.value=document.1stvisibleformname.resources.option[document.1stvisibleformname.resources.selectedIndex].value;
    document.hiddenform2.hiddenObject2.value = this.options[this.selectedIndex].value;
    document.hiddenform2.submit();You will then come across a similar problem with your third drop-down if indeed you need to resubmit the form...
    A far better approach would be to create a session scoped bean, and a servlet to handle these requests. Then when the servlet is called, it would set the value of the bean property, thus making it available for this request, and all subsequent requests within the current session. This approach would eliminate the need for the clunky javascript, making your application far more stable.

  • How to get HttpServletRequest parameters from two forms in a JSP

    I have this JSP with two forms calling the same servlet. Problem is, when I use a submit button in the second form, I am unable to retrieve the request parameters from the form through the servlet. I am wondering if anybody could give me some info on how to get the request parameters from the second form. I tried to see all the parameter names in the request by calling request.getParameterNames(). But the parameters in the second form are not even seen in the request although I am clicking the submit button in this form!

    First, two forms works fine in one jsp so no need to argue about that.
    Second, did you put the form actions and type ("multipart/formdata " ?) explicit in every form header ? Did you supply different form names ?
    Try to call the submit function through javascript - document.forms[0].submit() for your first, and document.forms[1].submit() for your second form...
    Did you forget to close the form tag by chance ?

Maybe you are looking for