English 中文(简体)
Javascript redirect
原标题:

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

最佳回答

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.

问题回答

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

window.location=window.location.href+redirectURL;




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签