views:

88

answers:

3

I am working with javascript and here is what I am trying to do: 1. Send a get request which looks like "http://localhost:8080/myapp/verify.htm?verifyId=Agkvhs"

My requests reaches my verify.jsp in which I have javascript which does some special things and then should redirect to another url WITH the verifyId . My code looks like this:

function saveAndRedirect() {
 var verifyId = "<%=request.getParameter("verifyId")%>";
 var redirectUrl = "registrationVerify?verifyId=" + verifyId;
 window.alert("Got value " + redirectUrl);
 window.location = redirectUrl;

}

However this does not work. I have an alert which shows me the correct URL with the appended parameter as I expect. In my web.xml file I have a servlet mapping with the following:

 <servlet-mapping>
     <servlet-name>RegistrationVerificationServlet</servlet-name>
     <url-pattern>/registrationVerify*</url-pattern>
 </servlet-mapping>

This mapping was workign before I appended the verifyId to the URL, I could see my request beign redicted to the servlet, since I appended this param it is not working. Any ideas much appreciated!

If this is not the ideal way to do this, please let me know any alternative.

Thanks

+1  A: 

Your url-pattern is suspicious.

Use either

/registrationVerify

to cover the exact path or

/registrationVerify/*

to cover the part of pathinfo. Note that you don't explicitly need the last one to be able to accept request parameters, if you'd thought that.

BalusC
This worked like a charm :-) Thank you, appreciate it!
msharma
You're welcome. However if you receive an answer which actually did answer your question, please set the answer to 'accepted' by ticking the accept mark below the vote buttons. Keep your 'accept rate' in eye as well, it is namely relatively low. You can find all of your previous (and unaccepted) questions here: http://stackoverflow.com/users/106401/msharma
BalusC
A: 

This is a bit of a long-shot, but does this line change help?

window.location=window.location.href+redirectURL;
michael
A: 

Many thanks everyone... simply changing the mapping to:

/registrationVerify/*

solved the problem, my request is being redirected with the parameter also :-) Many thanks to BalusC and others for responding!

Regards.

msharma

related questions