0

HttpServletRequest getServletContext() method not found

HttpServletRequest getServletContext() method is not found even in servlet3

17th Apr 2017, 5:36 PM
Midhun Mithran
Midhun Mithran - avatar
10 Respostas
+ 2
Write here the error message too. Without that is is hard to help.
18th Apr 2017, 6:23 AM
Tamás Barta
Tamás Barta - avatar
+ 1
req.getSession().getServletContext()
17th Apr 2017, 6:40 PM
Tamás Barta
Tamás Barta - avatar
+ 1
Check the servlet API. This method requires a String parameter, do you pass one?
18th Apr 2017, 6:17 AM
Tamás Barta
Tamás Barta - avatar
+ 1
Check the API. The parameterless version has an "s" in the end of the name: getServletRegistrations. There is no other method. http://docs.oracle.com/javaee/6/api/javax/servlet/ServletContext.html#getServletRegistration(java.lang.String)
18th Apr 2017, 6:23 AM
Tamás Barta
Tamás Barta - avatar
+ 1
You won't be able to finish a project if you don't think or you don't try to find out what the problem is. Your last post is the same as your first. You call the getServletContext() of HttpServletRequest which doesn't exists. My first post was: req.getSession().getServletContext().
18th Apr 2017, 6:40 AM
Tamás Barta
Tamás Barta - avatar
0
thanks for responding.. now I am getting not found error for getServletRegistration().
18th Apr 2017, 6:05 AM
Midhun Mithran
Midhun Mithran - avatar
0
nope. both methods are there .. with and without parameters.. i tried with parameters also 😣
18th Apr 2017, 6:21 AM
Midhun Mithran
Midhun Mithran - avatar
0
oops.. that's my mistake.. i just missed.. it is registrations ()
18th Apr 2017, 6:25 AM
Midhun Mithran
Midhun Mithran - avatar
0
Map<String, ? extends servletRegistration> sr = reg.getServletContext().getServletRegistrations(); i am getting cannot resolve method getServletContext() error
18th Apr 2017, 6:37 AM
Midhun Mithran
Midhun Mithran - avatar
0
yah. i tried with getSession() then it is showing same error in getServletRegistrations ()
18th Apr 2017, 6:44 AM
Midhun Mithran
Midhun Mithran - avatar