Amigos,
como pego o contexto da URL completa,
fiz conforme abaixo mas não esta como preciso
ExternalContext externalContext = context.getExternalContext();
HttpSession httpSession = (HttpSession) externalContext.getSession(true);
httpSession = (HttpSession) externalContext.getSession(true);
String contextPath = httpSession.getServletContext().getContextPath();
System.out.println("Contexto da Aplicação: " + contextPath);
gostaria de obter como por exemplo http://localhost:8089/projetoTal/…
e da forma que estou fazendo estou pegando apenas projetoTal/…
Cara,
no meu caso eu criei um Filter para validar um usuário logado sim ou não, configurei isso no meu web.xml,
configuração web.xml
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>br.com.sistema.login.security.SecurityFilterLogin</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain filterChain) throws IOException, ServletException {
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
HttpSession httpSession = httpServletRequest.getSession();
String servletPath = httpServletRequest.getServletPath();
System.out.println("CONTEXTO: " + httpServletRequest.getServerName() + ":"+ httpServletRequest.getLocalPort() + httpServletRequest.getContextPath());
}