Hi Stephan,
That's just a typo. See the cut down version below!
Let me switch to what I've been doing to what I'd like to do with this portlet is as follows.
1) User logs in and sees portlet that displays a link.
2) User clicks on link to name.jsp
3) name.jsp is executed and then redirects the user to a remote application
The reason I think I'm getting null/NPE is because when the link is clicked the sesion information is lost- I may be wrong but I don't have any other explanation for this. I really don't care to have this particular link. Any link (even fake one) would be fine. The behaviour that I want is for the portlet to present some link the first time it's rendered and upon clicking this link the user attributes (name, passwd) could be passed to the remote application that would then open in its own browser window.
=====================================================================
protected void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException
{
String username="Jeff";
PortletSession session=request.getPortletSession();
session.setAttribute("username", username, PortletSession.APPLICATION_SCOPE);
request.setAttribute("username", username);
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<table border=\"0\" width=\"100%\">");
out.println("<tr>");
out.println("<td>");
//provide clickable link for the user
out.println("<a resource window\" href=http://mail.yahoo.com/config/login?/\"" +
request.getContextPath() + "/jsp/name.jsp" + "\">click here</a>");
out.println("</td>");
out.println("</tr>");
out.println("</table>");
PortletContext portletContext = getPortletContext();
PortletRequestDispatcher prd = portletContext.getRequestDispatcher("/jsp/name.jsp");
prd.include(request, response);
}
code:
//name.jsp file
<%@ page import="javax.portlet.RenderRequest" %>
<%@ page import="javax.portlet.RenderResponse" %>
<%@ page import="javax.portlet.PortletPreferences" %>
<%@ page import="javax.portlet.PortletSession" %>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
<!--%@ page session="false" %-->
<portlet
efineObjects/>
//puzzle value of username null- why?
<% String name =(String)session.getAttribute("username"); %>
<%= name %>
<% String uname=(String)request.getAttribute("username"); %>
<%= uname %>