I have an EmailVerification
Servlet mapped with /ev/*
url-pattern.
http://example.com/ev/ce52320570
How can I get this ce52320570
part of the URL in my Servlet?
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String vid = ""; // Here I need to get the id from the URL
}
HttpServletRequest
methods. If you could substitute them for query parameters everything would be easier. – skuntselhttp://xyz.com/ev/ce52320570/
- having an extra/
in the end . it looks a bit of extra work to split and replace stuff. Do you have any better way for this ? – JAVAGeekhttp://xyz.com/ev/ce52320570/
,request.getPathInfo()
gives you the string/ce52320570/
. If you want to eliminate the"/"
s, just callString#replace()
:String vid = request.getPathInfo().replace("/", "");
. It will give you exactlyce52320570
. And this is file system independent. – acdcjunior