the servlet is
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class ServletWriteHtml extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException
{
PrintWriter out = response.getWriter();
java.util.Date today = new java.util.Date();
out.println("html" +
"
" +"
Write Html
"
+ "
" + today + "
}
}
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
And
ServletWriteHtml
ServletWriteHtml
/Alfa
index.html
compiled the servlet and put at WEB-INF folder
the url of the servlet is [^]
HTTP Status 404 - Not Found
type Status report
messageNot Found
descriptionThe requested resource is not available.
GlassFish Server Open Source Edition 4.1.1
What I have tried:
ran the application from ide , compiled the servlet and tried the url through web browser
解决方案
In your web xml . value is different in tag and tag. So server cannot map to correct servlet. You have to use same servlet-name value for both servlet and servlet-mapping tags
[^Read oracle docs for more info]
And
ServletWriteHtml
And
/Alfa
tip: reply to the comments in reply section and not as an answer.
the ide is netbeans, glassfish server has been deployed and the application is launched from web console, .class file has been created and is at web-inf directory still the error is 404 not found
And
Javas.ServletWriteHtml
And
/Alfa
changed the servlet name and added ServletWriteHtml at Javas package still 404 not found