I am trying to learn some JSP programming with Eclipse and I am having some issues:
Here is what I have:
1) Have test.jsp file inside WebContent folder that simply displays "Hello World!". I selected file and clicked Run As. Asked me to restart Tomcat server. Clicked Yes and page opened inside Eclipse showing "Hello World!".
2) I wrote Car class and stored it inside Java Resources/src
3) Tried to reference Car class in my test JSP and everything seemed right. (code below)
<%@ page import="ws.example.*" %>
<%
car myCar = new car("dodge", "neon");
out.println(myCar.getMake());
&>
4) Clicked "Run As" again and I got Hello World message. Clicked refresh, error showed up that car MyCar = new car("dodge", "neon"); cannot be resolved to a type.
5) Clicked Refresh again 2 times and second time message "Hello World!" showed up.
6) Kept clicking Refresh button and sometime I would have error, sometime Hello World. I understand that Hello World is coming from cash, but how can I avoid this? Very annoying.
Questions:
1) When I make change in my project, how can I make sure those changes are included when I start the project?
2) Where is the good place to store your classes? Obviously what I try didn't work.
UPDATED:
Here is my class:
package ppp;
public class MyCar {
String make;
String model;
public MyCar(String make, String model) {
this.make = make;
this.model = model;
}
public String getMake()
{
return make;
}
public String getModel()
{
return model;
}
}
here is my JSP code (NewFile.jsp):
<%
ppp.MyCar car = new ppp.MyCar("", "");
%>
Project Structure:
TestProject
- Deployment Descriptor: TestProject
- Java Resources
- src
- MyCar.java
- Libraries
- ...
- JavaScript Resources
- build
- WebContent
- META-INF
- WEB-INF
- NewFile.jsp
I just don't see any room for error here.
thanks