¿Cómo debo acceder al ServletContext desde un .jsp? Por ejemplo, cómo puedo llamar al método getRealPath desde dentro de .jsp.Java (JSP/Servlet): equivalente de getServletContext() desde adentro de .jsp
Aquí es un Servlet, que funciona bien:
protected void doGet(
HttpServletRequest req,
HttpServletResponse resp
) throws ServletException, IOException {
resp.setContentType("text/html; charset=UTF-8");
final PrintWriter pw = resp.getWriter();
pw.print("<html><body>");
pw.print(getServletContext().getRealPath("text/en"));
pw.print("</body></html>");
pw.flush();
pw.close();
}
Ahora estoy buscando la línea exacta que tengo que insertar en el siguiente .jsp a hacer exactamente lo mismo que el servlet arriba está haciendo.
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<body>
... // What should I insert here
</body>
</html>
Vea también http://stackoverflow.com/questions/2964250/jsp-getservletcontext-error – Vadzim