compile:
[javac] Compiling 1 source files to C:\...\workspace\proj\build\WEB-INF\classes
[javac] C:\...\workspace\proj\src\main\Helper.java:26: cannot find symbol
[javac] symbol  : method getServletContext()
[javac] location: interface javax.servlet.http.HttpServletRequest
[javac]     return getURISet(request.getServletContext());
[javac]                       ^
[javac] Note: C:\...\workspace\proj\src\main\Helper.java uses unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 1 error

Solution

The getServletContext() method is introduced in Servlet 3.0, not 2.3. But if you want to get the ServletContext then an alternative method to get it is:

1 ServletContext context = request.getSession().getServletContext();
2 
3 if (username != "" & username != null ) {
4     context.setAttribute("savedUserName", username);
5 }
6 writer.println("Context Parameter : " + (String)context.getAttribute("savedUserName"));

This way you can get the stored Request Parameter Value in different browser....

Reference

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-13
  • 2021-12-03
  • 2022-01-17
  • 2021-08-27
  • 2021-11-07
  • 2021-08-14
猜你喜欢
  • 2022-02-18
  • 2022-02-12
  • 2021-04-02
  • 2021-04-10
  • 2022-02-09
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案