Hello I am trying to do the following:
(At a high level)
1) Create a session variable in your application where you would store the "parentId"
e.g.
request.getSession().setAttribute("parentId",114);
2) In the report where you are using the parentId to filter the query you will have to read the session variable and add it to the query instead of the report parameter value. However, inorder to make it run from your desktop you may need the parameter otherwise it will always be null.
e.g. in the beforeOpen method of the query
var sessionParentId = null
sessionParentId= reportContext.getHttpServletRequest().getSession().getAttribute("parentId");
if
(sessionParentId== null)
sessionParentId = params[
"parentId"].value;
this.queryText = 'select distinct home_short_name from home where parent_id = ' +sessionParentId;
While calling the report do not pass the parentId in the URL.
-------------------------------------------------------------------------------------------------------------------------------------------------
I understand the beforeopen, I am having trouble with the session servlet described above.
I already have a servlet running the page, the page is displaying some dynamically hyperlinked items in xml 1.0 and because it is dynamically hyperlinked, it displays the parameter parentid on the URL when you click on the hyperlink and it also displays the parameter when you hover above it.
It is already using a bunch of servlets which utilize the following:
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
I don't have a very simple example of creating a session variable, and also I don't know where to put the code for the session variable, i.e., should I put it in with the other servlets:
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
I have been told this session is only necessary on two dynamically hyperlinked landing pages. It would break the whole application if I introduced it globally to the application.
My question to Seetharaman is this:
servlet often used in multi threading environment. so dont define HttpSession as an instance variable.
What should I do if I don't define a httpsession? Thanks,