如何使用Java Servlet从激活链接获取数据

我正在使用GWT,然后用户注册,我需要向用户发送带有激活链接的邮件。 激活链接可能包含用户的用户名和散列值。 使用PHP,我知道使用get方法检索这些值。 我是新的GWT Java,我希望能够在激活链接中获取值。我也在服务器上使用Java。 我只是想知道,在点击激活链接(其中包含一些数据来识别用户)后,当用户被重定向到我的网站时,我需要做什么。     
已邀请:
这与GWT无关。当用户单击激活链接时,将调用您的servlet。例如,您有一个servlet映射到
/useractivate
,您的URL是
http://yoursite.com/useractivate?hash=4342bc322&user=foo
。 然后在你的servlet的
doGet()
方法中你需要调用:
String hash = request.getParameter("hash");
String user = request.getParameter("user");
// .. handle activation
    
您也可以使用
RequestBuilder
在GWT中调用
HTTP.GET
方法。看看RequestBuilder.GET及其用法 我认为它会对你有所帮助,我建议你看看类似的主题 - 在GWT中发出http请求 从GWT教程:
import com.google.gwt.http.client.*;
...

String url = "http://www.myserver.com/getData?type=3";
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode(url));

    try {
      Request request = builder.sendRequest(null, new RequestCallback() {
        public void onError(Request request, Throwable exception) {
           // Couldn't connect to server (could be timeout, SOP violation, etc.)
        }

        public void onResponseReceived(Request request, Response response) {
          if (200 == response.getStatusCode()) {
              // Process the response in response.getText()
          } else {
            // Handle the error.  Can get the status text from response.getStatusText()
          }
        }
      });
    } catch (RequestException e) {
      // Couldn't connect to server
    }
    

要回复问题请先登录注册