The problem is that you're setting the session attribute twice in your page, so when the JSP generated the view, it will execute all your scriptlets. Basically, your JSP is doing this:
session.setAttribute("logtype", "hire");
//later...
session.setAttribute("logtype", "work");
Note that all the scriptlet code is executed when rendering the view (in simple words, when translating the JSP to HTML).
As stated by David Newton in comments the problem is Not "where", "when". Since it looks you want to change the session attribute in the form POST, this should be handled in your action POST request. And again, since you're doing all in JSP, this should be in your displayTasks.jsp page:
session.setAttribute("logtype", "work");
And remove this line from your current page (whatever name it has).
Not directly related to the current problem, but you have serious problems developing Java web applications. First thing to know, Java runs at server (as explained before, when rendering the view) while JavaScript runs at client browser, so it's not a good idea to make both interact at the same level directly. After realizing this, you must avoid scriptlets usage as is heavily explained here: How to avoid Java code in JSP files? and then move to EL and JSTL.
Now, you will realize that there are something else wrong with your current development approach. You're handling the GET and POST requests directly using JSPs. If you're in learning phase, I strongly discourage to do this and use Servlets instead for server side data processing. Know with all these tools, your development willbe accordingly to the MVC pattern, I provide you a basic login implementes in JSP + Servlet example: Creating a user object from login parameters.
Then after earning more experience in web development, you would want to try ajax. Here's a good tutorial on JSP, Servlets and Ajax: How to use Servlets and Ajax?