Bug 383498 - ServletContext cannot be resolved to a type
Summary: ServletContext cannot be resolved to a type
Status: RESOLVED WORKSFORME
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: jst.jsp (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: jst.jsp CLA
QA Contact: Nick Sandonato CLA
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2012-06-25 19:11 EDT by Sagar Kharel CLA
Modified: 2012-08-13 10:51 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sagar Kharel CLA 2012-06-25 19:11:39 EDT
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-->
Comment 1 Nitin Dahyabhai CLA 2012-06-25 20:21:21 EDT
Is ServletContext on your project's Java Build Path?  Are you able to write a normal Java Servlet in this project?
Comment 2 Nick Sandonato CLA 2012-08-13 10:51:11 EDT
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.