You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Raghuveer Rawat <te...@gmail.com> on 2008/05/07 19:17:58 UTC

Action servlet becomes null in UNIX environment

Hi,
I have a problem with my application where actionServlet becomes null in
UNIX environment and works fine in windows XP system. While saving data on
test environment (UNIX) I am getting action servlet as null in My Action
class. The jsp is built dynamically in as below

*JSP code:*

if (newGuide) {

sb.append("<tr>\n");

sb.append("<td align=right colspan=2>\n");

sb.append("<select name=\"actionSelection\">");

sb.append(" <option value=saveOnly>- Save Assessment</option>");

sb.append(" <option value=delete>- Delete Assessment</option>");

sb.append(" <option value=saveSchedule>- Save & Schedule</option>");

sb.append(" <option value=saveRefer>- Save & Refer</option>");

sb.append("</select>");

sb.append(" <input type=\"submit\" name=\"save\"

value=\"Complete\" class=Button >");

sb.append("</td>\n");

sb.append("</tr>\n");

}

* Action Class // Action class used for security *

public void setServlet(ActionServlet actionServlet) {

super.setServlet(actionServlet); // Here I get actionServlet as null

ServletContext servletContext = actionServlet.getServletContext();

WebApplicationContext wac = WebApplicationContextUtils

.getRequiredWebApplicationContext(servletContext);

setIcrProcessor((CareRequestProcessor)wac.getBean("myCareRequestProcesso

r"));

}

Because of this I get null pointer exception in class Main Action Class used
for saving the data.

*Action class code :*

public ActionForward saveHAGuide(ActionMapping mapping, ActionForm form,
HttpServletRequest request,

HttpServletResponse response) throws Exception {

String method = "saveHAGuide";

Exception ex = null;

ActionForward forward = null;

AppUser appUser = getAppUser(request);

appUser.methodStart(this, "saveHAGuide");

HttpSession session = request.getSession(false);

String action = request.getParameter("actionSelection"); // Here I get
action as null

Action becomes null and it throws null pointer exception.

As UNIX is case sensitive I checked the request parameter which is
actionSelection in this class and I do not see any problem with it. I don't
know why action servlet becomes null at this point. Please suggest if you
have any idea about this.

Note: This happens only in test environment (UNIX). Works fine in my local
system (Windows XP) .

Thanks and regards,

RE: Action servlet becomes null in UNIX environment

Posted by "Allen, Daniel" <Da...@kbcfp.com>.
> are using html in java code because the JSP changes at run time
according to
> the user inputs.

But that's exactly what the Logic tags are for: a JSP that produces
different output according to inputs. For example:
If, in your Java code, you have:
if (reqType == A)
	sb.append ("User made request A");

You can instead have in a JSP file (I'm using struts 2 tags because it's
what I know, but there are s1 equivalents):
<s:if test="reqType == A">
	User made request A
</s:if>

Both of those should do the same thing. I suppose it's beside the point
if you're stuck with the current design, though.

Anyway, did you check out the request object's contents? If the
parameter is indeed missing from the request, then the next step is to
find out what should
Be putting it into the request (probably the previous page, I'd guess)
and make sure that is putting it in. If it seems like the incoming URLs
are correct, including that parameter, then it looks like you have an
Apache or Tomcat problem, and you should probably ask them about it.

~DVA

-----Original Message-----
From: Raghuveer Rawat [mailto:techhelp07@gmail.com] 
Sent: Wednesday, May 07, 2008 2:45 PM
To: Struts Users Mailing List
Subject: Re: Action servlet becomes null in UNIX environment

Thanks for the prompt reply. Its a late 90's   huge application in which
now
i cannot start using Strus 2  as iam the only developer working on this.
We
are using html in java code because the JSP changes at run time
according to
the user inputs . Yeah , i agree that coz of diff environment we face
lot of
problems but i cannot do anything as its not my decision.
We  run Apache as a front end for Tomcat. Apache serves up the html
pages
and uses mod_jk mounts to forward the java application requests to
Tomcat.
I'll try to find out what else i can do as i am unable to see anything
in
apache logs as well.

On Wed, May 7, 2008 at 1:48 PM, Allen, Daniel <Da...@kbcfp.com>
wrote:

> A couple of things strike me as really odd about this.
>
> First: why are you creating HTML using strings in Java code? The whole
> point of JSPs was to avoid doing exactly that. You should either make
> use of .jsp files and the logic tags in Struts [1] or just use regular
> servlets if you really want to manually compose HTML.
>
> Second, why is your test environment different from your production
> environment? That sort of defeats the purpose of testing, since you
can
> no longer rely on the fact that something you tested works.
>
>
> That said, chances are pretty good that you're getting null from that
> line because the HTTP request represented by the request object didn't
> have a parameter called "actionSelection". I suggest you stick in a
> breakpoint and have a look at the contents of the object.
>
> Hope that helps.
> ~DVA
>
> [1] http://struts.apache.org/1.3.8/struts-taglib/index.html Looks as
> though you're using Struts 1, but you didn't specify a version, so
> here's the last release's tag documents. If this is a new app, may I
> humbly suggest you use Struts2 instead?  No sense in starting a
project
> using a deprecated framework.
>
>
> -----Original Message-----
> From: Raghuveer Rawat [mailto:techhelp07@gmail.com]
> Sent: Wednesday, May 07, 2008 1:18 PM
> To: Struts Users Mailing List
> Subject: Action servlet becomes null in UNIX environment
>
> Hi,
> I have a problem with my application where actionServlet becomes null
in
> UNIX environment and works fine in windows XP system. While saving
data
> on
> test environment (UNIX) I am getting action servlet as null in My
Action
> class. The jsp is built dynamically in as below
>
> *JSP code:*
>
> if (newGuide) {
>
> sb.append("<tr>\n");
>
> sb.append("<td align=right colspan=2>\n");
>
> sb.append("<select name=\"actionSelection\">");
>
> sb.append(" <option value=saveOnly>- Save Assessment</option>");
>
> sb.append(" <option value=delete>- Delete Assessment</option>");
>
> sb.append(" <option value=saveSchedule>- Save & Schedule</option>");
>
> sb.append(" <option value=saveRefer>- Save & Refer</option>");
>
> sb.append("</select>");
>
> sb.append(" <input type=\"submit\" name=\"save\"
>
> value=\"Complete\" class=Button >");
>
> sb.append("</td>\n");
>
> sb.append("</tr>\n");
>
> }
>
> * Action Class // Action class used for security *
>
> public void setServlet(ActionServlet actionServlet) {
>
> super.setServlet(actionServlet); // Here I get actionServlet as null
>
> ServletContext servletContext = actionServlet.getServletContext();
>
> WebApplicationContext wac = WebApplicationContextUtils
>
> .getRequiredWebApplicationContext(servletContext);
>
>
setIcrProcessor((CareRequestProcessor)wac.getBean("myCareRequestProcesso
>
> r"));
>
> }
>
> Because of this I get null pointer exception in class Main Action
Class
> used
> for saving the data.
>
> *Action class code :*
>
> public ActionForward saveHAGuide(ActionMapping mapping, ActionForm
form,
> HttpServletRequest request,
>
> HttpServletResponse response) throws Exception {
>
> String method = "saveHAGuide";
>
> Exception ex = null;
>
> ActionForward forward = null;
>
> AppUser appUser = getAppUser(request);
>
> appUser.methodStart(this, "saveHAGuide");
>
> HttpSession session = request.getSession(false);
>
> String action = request.getParameter("actionSelection"); // Here I get
> action as null
>
> Action becomes null and it throws null pointer exception.
>
> As UNIX is case sensitive I checked the request parameter which is
> actionSelection in this class and I do not see any problem with it. I
> don't
> know why action servlet becomes null at this point. Please suggest if
> you
> have any idea about this.
>
> Note: This happens only in test environment (UNIX). Works fine in my
> local
> system (Windows XP) .
>
> Thanks and regards,


-- 
This message may contain confidential, proprietary, or legally privileged information. No confidentiality or privilege is waived by any transmission to an unintended recipient. If you are not an intended recipient, please notify the sender and delete this message immediately. Any views expressed in this message are those of the sender, not those of any entity within the KBC Financial Products group of companies (together referred to as "KBC FP"). 

This message does not create any obligation, contractual or otherwise, on the part of KBC FP. It is not an offer (or solicitation of an offer) of, or a recommendation to buy or sell, any financial product. Any prices or other values included in this message are indicative only, and do not necessarily represent current market prices, prices at which KBC FP would enter into a transaction, or prices at which similar transactions may be carried on KBC FP's own books. The information contained in this message is provided "as is", without representations or warranties, express or implied, of any kind. Past performance is not indicative of future returns.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Action servlet becomes null in UNIX environment

Posted by Raghuveer Rawat <te...@gmail.com>.
Thanks for the prompt reply. Its a late 90's   huge application in which now
i cannot start using Strus 2  as iam the only developer working on this. We
are using html in java code because the JSP changes at run time according to
the user inputs . Yeah , i agree that coz of diff environment we face lot of
problems but i cannot do anything as its not my decision.
We  run Apache as a front end for Tomcat. Apache serves up the html pages
and uses mod_jk mounts to forward the java application requests to Tomcat.
I'll try to find out what else i can do as i am unable to see anything in
apache logs as well.

On Wed, May 7, 2008 at 1:48 PM, Allen, Daniel <Da...@kbcfp.com>
wrote:

> A couple of things strike me as really odd about this.
>
> First: why are you creating HTML using strings in Java code? The whole
> point of JSPs was to avoid doing exactly that. You should either make
> use of .jsp files and the logic tags in Struts [1] or just use regular
> servlets if you really want to manually compose HTML.
>
> Second, why is your test environment different from your production
> environment? That sort of defeats the purpose of testing, since you can
> no longer rely on the fact that something you tested works.
>
>
> That said, chances are pretty good that you're getting null from that
> line because the HTTP request represented by the request object didn't
> have a parameter called "actionSelection". I suggest you stick in a
> breakpoint and have a look at the contents of the object.
>
> Hope that helps.
> ~DVA
>
> [1] http://struts.apache.org/1.3.8/struts-taglib/index.html Looks as
> though you're using Struts 1, but you didn't specify a version, so
> here's the last release's tag documents. If this is a new app, may I
> humbly suggest you use Struts2 instead?  No sense in starting a project
> using a deprecated framework.
>
>
> -----Original Message-----
> From: Raghuveer Rawat [mailto:techhelp07@gmail.com]
> Sent: Wednesday, May 07, 2008 1:18 PM
> To: Struts Users Mailing List
> Subject: Action servlet becomes null in UNIX environment
>
> Hi,
> I have a problem with my application where actionServlet becomes null in
> UNIX environment and works fine in windows XP system. While saving data
> on
> test environment (UNIX) I am getting action servlet as null in My Action
> class. The jsp is built dynamically in as below
>
> *JSP code:*
>
> if (newGuide) {
>
> sb.append("<tr>\n");
>
> sb.append("<td align=right colspan=2>\n");
>
> sb.append("<select name=\"actionSelection\">");
>
> sb.append(" <option value=saveOnly>- Save Assessment</option>");
>
> sb.append(" <option value=delete>- Delete Assessment</option>");
>
> sb.append(" <option value=saveSchedule>- Save & Schedule</option>");
>
> sb.append(" <option value=saveRefer>- Save & Refer</option>");
>
> sb.append("</select>");
>
> sb.append(" <input type=\"submit\" name=\"save\"
>
> value=\"Complete\" class=Button >");
>
> sb.append("</td>\n");
>
> sb.append("</tr>\n");
>
> }
>
> * Action Class // Action class used for security *
>
> public void setServlet(ActionServlet actionServlet) {
>
> super.setServlet(actionServlet); // Here I get actionServlet as null
>
> ServletContext servletContext = actionServlet.getServletContext();
>
> WebApplicationContext wac = WebApplicationContextUtils
>
> .getRequiredWebApplicationContext(servletContext);
>
> setIcrProcessor((CareRequestProcessor)wac.getBean("myCareRequestProcesso
>
> r"));
>
> }
>
> Because of this I get null pointer exception in class Main Action Class
> used
> for saving the data.
>
> *Action class code :*
>
> public ActionForward saveHAGuide(ActionMapping mapping, ActionForm form,
> HttpServletRequest request,
>
> HttpServletResponse response) throws Exception {
>
> String method = "saveHAGuide";
>
> Exception ex = null;
>
> ActionForward forward = null;
>
> AppUser appUser = getAppUser(request);
>
> appUser.methodStart(this, "saveHAGuide");
>
> HttpSession session = request.getSession(false);
>
> String action = request.getParameter("actionSelection"); // Here I get
> action as null
>
> Action becomes null and it throws null pointer exception.
>
> As UNIX is case sensitive I checked the request parameter which is
> actionSelection in this class and I do not see any problem with it. I
> don't
> know why action servlet becomes null at this point. Please suggest if
> you
> have any idea about this.
>
> Note: This happens only in test environment (UNIX). Works fine in my
> local
> system (Windows XP) .
>
> Thanks and regards,
>
> --
> This message may contain confidential, proprietary, or legally privileged
> information. No confidentiality or privilege is waived by any transmission
> to an unintended recipient. If you are not an intended recipient, please
> notify the sender and delete this message immediately. Any views expressed
> in this message are those of the sender, not those of any entity within the
> KBC Financial Products group of companies (together referred to as "KBC
> FP").
>
> This message does not create any obligation, contractual or otherwise, on
> the part of KBC FP. It is not an offer (or solicitation of an offer) of, or
> a recommendation to buy or sell, any financial product. Any prices or other
> values included in this message are indicative only, and do not necessarily
> represent current market prices, prices at which KBC FP would enter into a
> transaction, or prices at which similar transactions may be carried on KBC
> FP's own books. The information contained in this message is provided "as
> is", without representations or warranties, express or implied, of any kind.
> Past performance is not indicative of future returns.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

RE: Action servlet becomes null in UNIX environment

Posted by "Allen, Daniel" <Da...@kbcfp.com>.
A couple of things strike me as really odd about this. 

First: why are you creating HTML using strings in Java code? The whole
point of JSPs was to avoid doing exactly that. You should either make
use of .jsp files and the logic tags in Struts [1] or just use regular
servlets if you really want to manually compose HTML.

Second, why is your test environment different from your production
environment? That sort of defeats the purpose of testing, since you can
no longer rely on the fact that something you tested works.


That said, chances are pretty good that you're getting null from that
line because the HTTP request represented by the request object didn't
have a parameter called "actionSelection". I suggest you stick in a
breakpoint and have a look at the contents of the object.

Hope that helps.
~DVA

[1] http://struts.apache.org/1.3.8/struts-taglib/index.html Looks as
though you're using Struts 1, but you didn't specify a version, so
here's the last release's tag documents. If this is a new app, may I
humbly suggest you use Struts2 instead?  No sense in starting a project
using a deprecated framework.


-----Original Message-----
From: Raghuveer Rawat [mailto:techhelp07@gmail.com] 
Sent: Wednesday, May 07, 2008 1:18 PM
To: Struts Users Mailing List
Subject: Action servlet becomes null in UNIX environment

Hi,
I have a problem with my application where actionServlet becomes null in
UNIX environment and works fine in windows XP system. While saving data
on
test environment (UNIX) I am getting action servlet as null in My Action
class. The jsp is built dynamically in as below

*JSP code:*

if (newGuide) {

sb.append("<tr>\n");

sb.append("<td align=right colspan=2>\n");

sb.append("<select name=\"actionSelection\">");

sb.append(" <option value=saveOnly>- Save Assessment</option>");

sb.append(" <option value=delete>- Delete Assessment</option>");

sb.append(" <option value=saveSchedule>- Save & Schedule</option>");

sb.append(" <option value=saveRefer>- Save & Refer</option>");

sb.append("</select>");

sb.append(" <input type=\"submit\" name=\"save\"

value=\"Complete\" class=Button >");

sb.append("</td>\n");

sb.append("</tr>\n");

}

* Action Class // Action class used for security *

public void setServlet(ActionServlet actionServlet) {

super.setServlet(actionServlet); // Here I get actionServlet as null

ServletContext servletContext = actionServlet.getServletContext();

WebApplicationContext wac = WebApplicationContextUtils

.getRequiredWebApplicationContext(servletContext);

setIcrProcessor((CareRequestProcessor)wac.getBean("myCareRequestProcesso

r"));

}

Because of this I get null pointer exception in class Main Action Class
used
for saving the data.

*Action class code :*

public ActionForward saveHAGuide(ActionMapping mapping, ActionForm form,
HttpServletRequest request,

HttpServletResponse response) throws Exception {

String method = "saveHAGuide";

Exception ex = null;

ActionForward forward = null;

AppUser appUser = getAppUser(request);

appUser.methodStart(this, "saveHAGuide");

HttpSession session = request.getSession(false);

String action = request.getParameter("actionSelection"); // Here I get
action as null

Action becomes null and it throws null pointer exception.

As UNIX is case sensitive I checked the request parameter which is
actionSelection in this class and I do not see any problem with it. I
don't
know why action servlet becomes null at this point. Please suggest if
you
have any idea about this.

Note: This happens only in test environment (UNIX). Works fine in my
local
system (Windows XP) .

Thanks and regards,

-- 
This message may contain confidential, proprietary, or legally privileged information. No confidentiality or privilege is waived by any transmission to an unintended recipient. If you are not an intended recipient, please notify the sender and delete this message immediately. Any views expressed in this message are those of the sender, not those of any entity within the KBC Financial Products group of companies (together referred to as "KBC FP"). 

This message does not create any obligation, contractual or otherwise, on the part of KBC FP. It is not an offer (or solicitation of an offer) of, or a recommendation to buy or sell, any financial product. Any prices or other values included in this message are indicative only, and do not necessarily represent current market prices, prices at which KBC FP would enter into a transaction, or prices at which similar transactions may be carried on KBC FP's own books. The information contained in this message is provided "as is", without representations or warranties, express or implied, of any kind. Past performance is not indicative of future returns.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org