Friends,
I apologize if this is a very basic question but it is throwing me.
I have JAVA-EE with Netbeans and the EE plugins. I am using Netbeans to create a simple HelloWorld type new
Servlet from scratch and in the process of doing so, it also creates a file that has a name like index.jsp too under WEB-INF. Ok, fine. However, when I try to select "Run Project" under the RUN menu in Netbeans, it runs the index.JSP file content and not the code in the Servlet (both the
JSP and the Servlet have a print statement within them with different "hello world" messages I edited which is how I know which one is running.)
So, if I click on "Run Project", the HTML web page that opens displays the contents from the index.JSP file.
That is, out of the box with no editing by me other than to change the two 'hello world' messages, after I create a new Servlet, I see that when I click on "Run Project" - all I get is the index.JSP file running in the browser.
However, if instead, I right-click the actual class_name.java file (under Source Packages) and then select "Run File" - then it runs my actual Servlet (and not the JSP apparently).
So, I can fix this by designating the 'welcome page' in the web.xml descriptor file to point to my project name (HelloWorld instead of index.jsp) file but I am wondering why does Netbeans generate both a JSP and a Servlet page and only run the JSP file when I do a "Run Project" command? That seems counter productive or at least counter-intuitive. But perhaps this is because of my lack of sufficient
JAVA knowledge (or Netbeans knowledge).
Oh, and I tried deleting the index.JSP file since as best I can tell I don't need it but then the browser cannot find a page to run. (good ole 404 error).
Any ideas on how these two files are "supposed" to work together?
Thanks - Jerry
p.s. - If I make ANY kind of changes to the index.jsp file, Netbeans will no longer run my project (not even with the 'welcome page' set up in web.xml). I just get a message that says "Saving Index" (which it does NOT actually do). I know this because I can open it in a different editor and it hasn't changed. Also, when I go to close Netbeans, it hasn't changed - and I can't actually save it. bummer...