Hey, I'm getting so fustrated with this now!! I'm making a site in jsp and I have created the registration page and the login page and everything works fine. However I want to start to use the session login to personalise the page depending if they have logged in or not. I thought I had done this using the following code as it worked fine once you had logged in but if you went to the page without logging in it throws a internal server error print stack trace error 500 with a NullPointerException.

<% if (sess.getAttribute("loggedUser").toString() == null) { %>
         <jsp:include page="\LoggedSessionMenu.jsp" />
      <% } else { %>
         <jsp:include page="NonSessionMenu.jsp" />
      <% } %>

I'm guessing its because the session is empty but I tried with an if statement to test if it is null and this didn't work either.
Any help would be awesome as I'm going mad trying to fix this!

The string you get back from the session is null, so your attempt to call toString() on it results in an NPE.
You should really use JSTL as well.
Something like

   <c:when test="not empty session.loggedUser">

Makes it immediately apparent what you're trying to do, and will not result in an NPE.