Salve.
Ho copiato questa servlet ed l'ho messa dentro un progetto Dynamic Web Project.
Solo che è inserita come un package, e volevo capire se è possibile far eseguire questa servlet come se fosse una jsp.
Ho provato a lanciarla con il comando run on server, ma come risposta ho un errore 404, praticamente non trovata.
codice:import java.util.Date; import java.text.SimpleDateFormat; import javax.servlet.*; import javax.servlet.http.*; import javax.servlet.jsp.*; import org.apache.jasper.runtime.*; import org.apache.jasper.runtime.JspException; public class Prima_Servlet extends HttpJspBase { static { } public Prima_Servlet () { } private static boolean _jspx_inited = false; public final void _jspx_init() throws org.apache.jasper.runtime.JspException { } public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { JspFactory _jspxFactory = null; PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; String _value = null; try { if (_jspx_inited == false) { synchronized (this) { if (_jspx_inited == false) { _jspx_init(); _jspx_inited = true; } } } _jspxFactory = JspFactory.getDefaultFactory(); response.setContentType("text/html;charset=ISO-8859-1"); pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true); application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); // HTML // begin [file="/corso_jsp/lezione1/esempio1.jsp";from=(0,63);to=(7,2)] out.write( "\r\n<html>\r\n<head>\r\n <title>Corso di JSP, Lezione 1, Esempio 1</title>" + "\r\n</head>\r\n<body>\r\n <h1>Questa è una pagina JSP!</h1>\r\n" ); // end // begin [file="/corso_jsp/lezione1/esempio1.jsp";from=(7,4);to=(7,60)] SimpleDateFormat sdf = new SimpleDateFormat("h:mm a"); // end // HTML // begin [file="/corso_jsp/lezione1/esempio1.jsp";from=(7,62);to=(8,17)] out.write("\r\n Sono le ore "); // end // begin [file="/corso_jsp/lezione1/esempio1.jsp";from=(8,20);to=(8,44)] out.print( sdf.format(new Date()) ); // end // HTML // begin [file="/corso_jsp/lezione1/esempio1.jsp";from=(8,46);to=(12,0)] out.write("\r\n</body>\r\n</html>\r\n\r\n"); // end } catch (Throwable t) { if (out != null && out.getBufferSize() != 0) out.clearBuffer(); if (pageContext != null) pageContext.handlePageException(t); } finally { if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext); } } }

Rispondi quotando