Results 1 to 6 of 6
  1. #1
    shortsmiler is offline Member
    Join Date
    Mar 2012
    Posts
    3
    Rep Power
    0

    Default reading parameters from URL

    Hi

    Apologies for this question as it is probably one of the simplest things to do but i have been looking at this issue for so long i am now starting to confuse myself more.

    I am wondering if someone would be able to point me in the direction of finding information on now to solve an issue i am encountered.

    I am trying unsuccessfully to create an application that will allow the user to sent a URL like http://www.abc.makeup/en/doSomething...vale&par2=val2 and then my application to be able to read the value of what par1 and par2 (after the URL clicked) and save these to variables with the doSomething. Is this even possible?

    I have edited the web.xml to redirect the application to the correct page when the URL contains the string "doSomething".

    The intention is that this will be done through java servlets.

    I have tried request.getParameter("par1"); but either i have defined this in the wrong place or it being called.

    Thanks for any help in advance

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,016
    Rep Power
    20

    Default Re: reading parameters from URL

    What code have you got?
    What is that code doing that it shouldn't?
    Do you have any errors?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    shortsmiler is offline Member
    Join Date
    Mar 2012
    Posts
    3
    Rep Power
    0

    Default Re: reading parameters from URL

    The code should be reading the values from the URL and putting them into variables to allow me to process and pass the values onto a web service which I have created. At present the code I have appear to be doing nothing. There are no errors being displayed.

    My code is below and I have break point at least to see if they are being initialized. Am I missing something so simple?

    protected void doGet(HttpServletRequest request,
    HttpServletResponse response) throws ServletException, IOException {

    final String par1 = request.getParameter("par1");
    final String par2 = request.getParameter("par2");

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,016
    Rep Power
    20

    Default Re: reading parameters from URL

    So is it getting into that doGet?
    WHen you say "redirect ... to the correct page" you do mean "forward" don't you?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    shortsmiler is offline Member
    Join Date
    Mar 2012
    Posts
    3
    Rep Power
    0

    Default Re: reading parameters from URL

    Apologies yes I mean that it forwards me to the correct page. As for the doGet method not it doesn't appear to be getting into this method at all (well it isn't hitting any of my breakpoint when the code is running in debugging mode).

    As for reading the parameters of the URL am what I trying to do the correct approach or have I got seriously lost along the way somewhere.

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,016
    Rep Power
    20

    Default Re: reading parameters from URL

    That's how you get the parameters from a request, yes.
    So you just need to figure out why it's not getting into the servlet.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 10
    Last Post: 01-24-2012, 10:02 PM
  2. Replies: 5
    Last Post: 11-21-2010, 02:08 PM
  3. Replies: 5
    Last Post: 08-21-2009, 11:03 AM
  4. How to add two other parameters?
    By albi_87m in forum Advanced Java
    Replies: 3
    Last Post: 05-18-2009, 01:25 PM
  5. get parameters in jsp
    By cecily in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 08-05-2007, 04:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •