Al barrejar Java i JSP apareixen diverses formes de fer-ho.... aquesta es la meva:
String myname=""
<%{
try {myname=request.getUserPrincipal().getName();}
catch(NullPointerException Exception) {myname="";}
if(myname=="")%> Hola Visitant<%}
else { %>Hola <%=myname%>
<%}%>
Enllaços que hauries de consultar:http://docs.oracle.com/javase/1.4.2/docs/api/java/security/Principal.html
http://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletRequest.html
http://docs.oracle.com/javaee/1.4/api/javax/servlet/ServletRequest.html
No hay comentarios:
Publicar un comentario