Re: Issue with ServletActionContext.getRequest() returning null in JSP (Struts 7)

Lukasz Lenart <[email protected]> Tue, 1 Apr 2025 07:42:59 +0200
Newsgroups gmane.comp.jakarta.struts.user
Message-ID <CAMopvkPm8K2E2gEwAF-nXNEvnvFNPc=SDgUPAq8KCEYVhsFgNQ@mail.gmail.com>
śr., 26 mar 2025 o 09:38 Lidin NT <[email protected]> napisał(a):
> Why is ServletActionContext.getRequest() returning null in JSP?

Calling JSPs directly is a Bad Idea
https://struts.apache.org/security/#never-expose-jsp-files-directly

And calling JSPs directly means you skip the whole Action related
machinery, with security checks and so on. That's why the context is
empty.

> How can I fix this issue so that userViewUtil returns the expected value?

As already mentioned by Wolfgang, wrap JSP with an action. If you
using the Convention plugin it should be as simple as Wolfgang says or
you can use Wildcard mapping


Regards
Łukasz