When i run the jsp , and click on submit button , I am getting the 404 errorr , the url is displayed as "http://localhost:8100/LoginServlet"
But the correct url should be http://localhost:8100/custTest/LoginServlet ...where should I make this change so that i dont get the error and the servlet gets invoked ?
Yes . Form tage looks like . I am using the JSP editor on my workspace. There are no errors and no warnings on my jsp ..
My project name is custTest . In the server.xml the contextpath = "/custTest" . Where should i check what is my context path ?
Still I am getting the 404 error ?
I have been trying hard to call a servlet from a jsp.. I have not been able to do it.. Please help ...
Got the below when i click submit on the jsp page. I find the servlet class in the same pakcage (directory) as the source java file. But the server does not picke up this class file .. did i miss any configuration ?
renaming the url mapping from /Test to /LoginServlet in your web.xml.
If you are using the absolute path, you probably need to use the actual servlet name vs. the url mapping because you are outside the context path.
I would recommend using all jsp navigation through servlets (request dispatcher) that way you stay within the context path and can use web.xml mappings.
Well, I had a very similar issue before and realized if you navigate from jsp to jsp using href etc, without going through a controller servlet, the web.xml mappings are broken and you must use the absolute path to servlets. In the initial post, the OP is trying to use the web.xml mapping. I wasn't sure if this was the same issue I had, but for lack of better terms, the web.xml controls the context of your web app and if that gets broken and you must use absolute mappings.. that also conflicts with the MVC architecture as some argued to me.. maybe i'm wrong
If the original url mapping set forth in the web.xml file wasn't working, mapping to it using an absolute path will probably not generate the desired results as well.
I wanted to get started with web programming... I tried creating a new workspace, new project , new servlet and a new jsp .. Looks like I am stuck with the same error I got yesterday.
I am getting the error - java.lang.ClassNotFoundException: javax.servlet.Servlet
I pasted all the files that i have on my workspace below . Please help me resolve this error..
Project Name : custASG.
Servlet Code
JSP Code : LoginPage.jsp
Web.xml
Default Output folder of my project : custASG/src
I am able to see the LoginServlet.class very next to the LoginServlet.java . They both are in the same package when I see in the Resource Perspective
Have you checked your war? Did it contain all the files (not what is shown in IDE), the actually deployable war. Are you sure, you have all the classes inside WEB-INF/classes
Also, see what does it print for ${pageContext.request.contextPath}. Do you actually see the servlet being hit when you type http://localhost:8100/custTest/LoginServlet in browser.
the url for my servlet is : http://localhost:8200/custASG/LoginServlet When i tried accessing this url directly on a web browser , I was gettign the same exception.
Also when i made some changes to jsp file , rebuild my project and reatarted the server, the server is still picking up the old jsp.
any idea why this could hapen and why my servlet is not getting picked up ?
I deleted the server and created a new one ....I got the jsp changes to work ... whatever changes i make on the jsp , its getting picked up the next time i restart the server ,,but when i click on the submit button on jsp , the url on the browser is
In your LoginPage.jsp, your form action should be :
Also, your web.xml had to be corrected. If you are only using LoginPage.jsp, then your <welcome-file-list> needs to include <welcome-file>LoginPage.jsp</welcome-file>
I've re-created your test servlet and tested it to ensure it is functioning properly.. Please review notes.. good luck