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
Re: reading parameters from URL
What code have you got?
What is that code doing that it shouldn't?
Do you have any errors?
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");
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?
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.
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.