Thursday, December 1, 2011

Get application url using java

/*
If your domain name is http://jijo84.blogspot.com/.
You will get http://jijo84.blogspot.com/ in your application using the following code.
If you are using struts action class, servlet or jsp  , you can use the following code.

*/

import java.net.URL;

public ActionForward checkUrl(ActionMapping mapping, ActionForm form, HttpServletRequest request,
            HttpServletResponse response) throws Exception {
URL applicationUrl = new URL(request.getScheme(), request.getServerName(), request.getServerPort(),
                        request.getContextPath());
system.out.println(applicationUrl.toString());
return mapping.findForward("success");
}




No comments: