This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi All, Thanks so much for your help over the last few days. Don't know what I would do without Javaranch! I have an app which will start up with a URL that looks like :
In my web.xml, I have
In index.jsp I have
In struts-config I have
in my InitAction class I have
My problem is that in the InitAction, the value of sessionID I get is null, even though on the URL I can see that there is a value appended there.
I think I must be missing something. Is there a way that I can bypass the trek through index.jsp and go right to the InitAction ? If not, am I missing something in my attempt to pass the PFSessionID parameter through to the action?
and then in the action tried a request.getParameter("jsessionid"); and request.getParameter("name");
both of these returned null.
The reason I am doing this is I want to compare the sessionID passed on the URL to the actual sessionID which I successfully do get usingrequest.getSession().getId(). I want to use the name parameter for another reason. I can't seem to get at either parameter though!
Joined: May 17, 2001
Well, am about to give up on this one. Found out that if I make my url include the action name (and remove the part of web.xml that directs user to index.jsp) I can pull the items off the URL fine. I seem to hit the problem when I go through the jsp page. I wanted to do it that way so I didnt have to have the action on the url since it looks a bit clunky, but cant seem to find a way around this and still be able to pull the params off of the url.
You can pass a parameter from your index.jsp. You just can't do it using the <logic:forward> tag.
Try it this way:
Note: The above will only work on web appliation that uses Servlet version 2.4 or above. Otherwise, you have to use a scriptlet for the value attribute. [ February 05, 2007: Message edited by: Merrill Higginson ]
I continue to get a null result for sessionID. I am glad I can get this to work by adding the \init.do to the url, but it is driving me nuts because I know I SHOULD be able to make this work the way you describe.
One more question I thought of in trying to figure this out is, when I am in the jsp page in the scriptlet, how does the jsp know that the reference to "request" means the HTTPServletRequest? Maybe I am supposed to specify that in a header or in the struts-config? Though this problem has been frustrating I am learning a ton in the process !
Joined: Feb 15, 2005
I don't know if you were just being careless in your post, but the code you posted is incorrect. It should read:
In answer to your question, the JSP specification dictates that there are certain "pre-defined" variables in any JSP. "request" is one of them, as is "session", "response", etc. This link contains a complete list.
A "pre-defined" variable means you don't have to declare it or instantiate it. The container does it for you. [ February 06, 2007: Message edited by: Merrill Higginson ]