Community
Participate
Working Groups
Build Identifier: Version: Indigo Service Release 2 Build id: 20120216-185 While you try to create ServletContext object (using this.getServletContext) in jsp scriptlet, eclipse shows the error (the red line) and the exact details when you focus on: 1)ServletContext is: Multiple annotations found at this line: - ServletContext cannot be resolved to a type - The method getServletContext() is undefined for the type __2F_Ch5Email_2F_WebContent_2F_display_5F_email_5F_entry_2E_jsp 2)this.getServletContext(); The method getServletContext() is undefined for the type __2F_Ch5Email_2F_WebContent_2F_display_5F_email_5F_entry_2E_jsp But, you can compile the code and it runs fine even though eclipse displays error. NetBeans does not report any error for this line. Even the intellisense (ctrl+space) does not suggest ServletContext. Reproducible: Always Steps to Reproduce: In JSP page use this scriplet: <% ServletContext sc = this.getServletContext(); String path = sc.getRealPath("/WEB-INF/EmailList.txt"); %> Path: <%= path> <!--Just to be sure above scriplet executed-->
Is ServletContext on your project's Java Build Path? Are you able to write a normal Java Servlet in this project?
I am unable to reproduce this. It looks like a case of the ServletContext not being on the build path. If you are sure it's on the build path, please reopen the defect. Thanks.