I've installed the Web Tools Project for Eclipse version 3.4. I've been trying to get refactoring working the way I think it should and have had no success.
I have one Java project that contains the Java classes for the jar that is put into the /WEB-INF/lib for a web site. Another project (a Dynamic Web project) has the JSP files for the same site. The Dynamic Web project is set up with the Java project as a required project in the build path. I have also set the Project References option for the Dynamic Web project to refer to the Java Project.
If I use refactoring to change a method name in one of the Java classes, I would expect that references to that method in the JSPs would be renamed. But it does not work. References in the Java project that contains the class and other Java projects that use that class have the references changed are refactored, but not references to the method inside the JSPs.
I've been fiddling with it for days, trying different versions of Eclipse and WTP. Deleting all my projects and files and setting them up again. Nothing makes any difference.
Does this work for anyone else? Is there something special I need to set to get this working?
Sorry, this is not directly answering your question but nevertheless addressing your problem... maybe it helps, otherwise please ignore:
As matt b suggested, you should not place java code in a jsp. Instead 'simply' use Tags. If you're using the standard tag library, there's almost everything there that you need. For things that you must handle yourself, it's very simple to write your own tags once you know what tags are about.
With this trick you'll get a better application (view) architecture, opportunity for tests (hope you like them), adhere to the DRY (dont repeat yourself) principle and place all Java code in .java files, so that they will easily be picked up by any tool.
There's even an option for web.xml to enforce disabling scripting, leaving tags working, but if you already have a huge investment in scripted jsps, this might not be what you need...
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<scripting-invalid>true</scripting-invalid>
</jsp-property-group>
</jsp-config>
Another answer to a question that you didn't ask is that IntelliJ Idea handles the scenario that you talk about very well (though I'm using eclipse myself day to day, this is one of the differences between both IDEs)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With