I am a newbie trying to create a sample web application using;
MySQL Java Tomcat JSP & Servlet
The ide I use is MyEclipse Blue Edition.
The persistence and service layer is done. Within web layer however I'm having trouble displaying the index.jsp, here is what I done so far, and what my expectations are:
- I have associated the project with tomcat 6, each time I run the project service is stopped and restarted the final line in log is INFO: Server startup in x ms
- I have created the web layer by selecting new web project from which an example index.jsp was already genereated in web root folder, I also checked that in web.xml ( I suppose this is going to be used by tomcat ) there is a tag called welcome-list indicating the first jsp that should be opened when the application starts. index.jsp is on that list.
- I have used a tutorial on how to use Servlets and extended HTTPServlet within a class at web layer, presently it does very little things, namely within index.jsp there is a button, upon clicking that button this class should forward request and responses and open up another jsp file, this I couldn't test yet.
Which brings us to my newbie question: Everytime I run the project server starts and then nothing happens. I'm expecting for MyEclipse to start displaying index.jsp on its own browser from which I can copy/paste the url to a regular browser. I'm expecting the url to be something like localhost:8080/index.jsp (tomcat runs on port 8080, in my computer).
Server seems to be running and I have tried different combinations but I can't seem ot display the index.jsp, whatever I try it is not found, what should I do ?
Edit1: Here is my web.xml code:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<welcome-file-list>
<welcome-file>/index.jsp</welcome-file>
</welcome-file-list>
</web-app>
Here is my servlet code: (I didn't get to test it so far, my main problem is not here)
public class CRMServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String action = request.getParameter("action");
System.out.println("ACTION : " + action);
if(action.equals("LoginRequest"))
{
request.setAttribute("bilgi", "cem");
request.getRequestDispatcher("Login.jsp").forward(request, response);
}
}
}