You did the same thing I did ,Please give a second thought of my post. Declaring variable outside the jspInit method doesn't change the output because we have to set attribute inside the method. It's not working.
best regards, omi
omi sharma
Ranch Hand
Joined: Mar 18, 2008
Posts: 489
posted
0
Originally posted by John Stone: try to remove this line from DD: <servlet-class>TestServlet</servlet-class>
LOL,what made you think if I remove the line ,it will be fine.
My friend,It will get bigger problem as big fat null pointer exception.
best regards, omi
omi sharma
Ranch Hand
Joined: Mar 18, 2008
Posts: 489
posted
0
The main problem is getInitParameter() does not get parameter for me, neither as stand-alone nor inside the method.
best regards, omi
John Stone
Ranch Hand
Joined: May 04, 2007
Posts: 332
posted
0
LOL,what made you think if I remove the line ,it will be fine.
The fact, that you have both <jsp-file> and <servlet-class> used in one <servlet> element.
omi sharma
Ranch Hand
Joined: Mar 18, 2008
Posts: 489
posted
0
So any idea? why I am getting nulls?
best regards, omi
John Stone
Ranch Hand
Joined: May 04, 2007
Posts: 332
posted
0
What URL are you typing in address bar? /Test.jsp or /Hobby.do?
John Stone
Ranch Hand
Joined: May 04, 2007
Posts: 332
posted
0
*.jsp is implicitly mapped to org.apache.jasper.servlet.JspServlet, so if you are writing .jsp in address bar, that could be the reason.
I feel that your statement "Actually init-param is not for jsp it's for servlet for jsp we use context-param like a charm" is "wrong".
Jsp is nothing but finally Servlet. We can also set "init-param" to JSP. Your solution of "<context-param>" is just alternate solution but you didn't fix the root cause.
John was right, actual problem is we can't have both "<jsp-file>" and "<servlet-class>" tag, at any time we can have only "<jsp-file>" or <servlet-class>" tag.
I would request you to check the first version of the code by removing the "<servlet-class>" tag.
Thanks.
Vijay Bheemineni.
omi sharma
Ranch Hand
Joined: Mar 18, 2008
Posts: 489
posted
0
Originally posted by Vijay Bharghav bheemineni: Hi Omi,
I feel that your statement "Actually init-param is not for jsp it's for servlet for jsp we use context-param like a charm" is "wrong".
John was right, actual problem is we can't have both "<jsp-file>" and "<servlet-class>" tag, at any time we can have only "<jsp-file>" or <servlet-class>" tag.
I would request you to check the first version of the code by removing the "<servlet-class>" tag.
Well my dear ,jsp is servlet for container not for client. If jsp is really servlet for client ,then please tell me why do we need to use <jsp-file> element in DD?
Yes , I know John was right.I did not know the whole story because I had form-parameters to access via servlet and then process it in jsp and a model java class.When I tried to remove <servlet-class> I got null-pointer exception so that time I thought what was he talking about.Later I knew what did he mean.
I already solved my problem. Thank you for reply.
best regards, omi [ May 23, 2008: Message edited by: omi sharma ]