Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 325306 - The "Use an existing Servlet class or JSP" option in the new servlet wizard does not work for Web 3.0 projects
Summary: The "Use an existing Servlet class or JSP" option in the new servlet wizard d...
Status: RESOLVED FIXED
Alias: None
Product: WTP Java EE Tools
Classification: WebTools
Component: jst.servlet (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: 3.2.3   Edit
Assignee: Carl Anderson CLA
QA Contact: Chuck Bridgham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 325990
  Show dependency tree
 
Reported: 2010-09-15 00:42 EDT by Carl Anderson CLA
Modified: 2010-09-28 17:46 EDT (History)
1 user (show)

See Also:
cbridgha: review+


Attachments
The aforementioned changes (5.33 KB, patch)
2010-09-15 00:58 EDT, Carl Anderson CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carl Anderson CLA 2010-09-15 00:42:04 EDT
Steps to reproduce:

1. Create a WEB 3.0 project (either with or without a DD)
2. Create a JSP page in the web project
3. Create a class in the web project that extends javax.servlet.http.HttpServlet
4. Open the new servlet wizard
5. Select the "Use an existing Servlet class or JSP" option, click the browse button, and select the JSP file. 
6. Finish the wizard (PROBLEM: The JSP file is opened, but nothing else happens)
7. Repeat steps 4-6, but now selecting the class instead of the JSP file ((PROBLEM: The class file is opened, but nothing else happens)
Comment 1 Carl Anderson CLA 2010-09-15 00:47:59 EDT
There are two problems that I found here:

1) The Browse button in step 5 gives an error if there are only JSPs in the Web project.  (This goes for all Java EE versions)

2) For any Servlet/Filter/Listener, if useExisting is selected, then we should ensure that the deployment descriptor is generated and the proper values are set.  The reason for this is that an annotated Servlet/Filter/Listener (or one already in the DD) would show an error and Finish would be disabled, thus the only case where useExisting would be true would be in the case of a non-annotated class file or a JSP (which cannot be annotated) being added, and thus the deployment descriptor should be updated.
Comment 2 Carl Anderson CLA 2010-09-15 00:57:30 EDT
For explanatory purposes, in debugging I noticed that the extensions are being set twice and a TypedFileViewerFilter with the exact same extensions are being added twice - once in the constructor for FilteredFileSelectionDialog, and again in the constructor for MultiSelectFilteredFileSelectionDialog.  I removed the ones from MultiSelectFilteredFileSelectionDialog.
I also modified the code to call setMessage only if the message passed in is null - if it is not null, setMessage is called by FilteredFileSelectionDialog (and then it was called again with exactly the same value).

I modified open() so that if there are no Servlets but are JSPs, the JSP radio button is selected (and the dialog still opens... previously, it would not open).  I also had to capture the contents of setInput(), since its superclass keeps it private, and I needed it to determine if there were any JSP files.
Comment 3 Carl Anderson CLA 2010-09-15 00:58:30 EDT
Created attachment 178895 [details]
The aforementioned changes
Comment 4 Carl Anderson CLA 2010-09-15 01:02:59 EDT
Kaloyan - I added you in the CC because of fix #2 in comment #1 .  I believe that is the correct fix to make, as per my logic, but wanted to make sure that your team agrees.

Marking for Chuck's review for inclusion in WTP 3.2.3 (once that opens up).
Comment 5 Kaloyan Raev CLA 2010-09-15 02:34:46 EDT
Carl, by "annotated" do you mean XDoclet annotation or Servlet 3.0 annotations?
Comment 6 Chuck Bridgham CLA 2010-09-17 16:14:37 EDT
approve
Comment 7 Carl Anderson CLA 2010-09-21 15:05:42 EDT
Kaloyan, I am referring to both types of annotations.  However, the XDoclet code will regenerate the web.xml entries for XDoclet servlets whenever a build is done.  Therefore, for both annotation scenarios, useExisting should be false, and thus the logic should be correct.
Comment 8 Carl Anderson CLA 2010-09-21 15:08:06 EDT
Committed to HEAD for WTP 3.3.  Once WTP 3.2.3 opens up, I will commit it there.  (Unless testing in HEAD encounters a scenario in which this is not correct.)
Comment 9 Carl Anderson CLA 2010-09-28 17:46:23 EDT
Committed to R3_2_maintenance for WTP 3.2.3