How to use a file.JSP
I am extremely new to the JSP language, I wanted to know how to use a jsp file that I created and exibile for example in the browser, the same way I do with html files, that is, how to use a jsp file created??? obs : in the attached image is the result when I open the file .JSP with the browser (which is not the output I want).
<%! int i %>
<html>
<head>
<title> Pagina JSP Ola Mundo</title>
</head>
<body>
<% for(i = 0; i = 3; i++){ %>
<div>
<%out.println("numero:"+i);%>
</div>
<%
}
%>
</body>
</hmtl>
2 answers
You cannot open a JSP file directly in the browser because it is a language "above" HTML. This means that you need a web container to identify the JSP components of the file and allow it to be viewed as an HTML file. The browser does not have native support for identifying these components, which is why you need your project containing the JSP to include the jsp-api
and jstl
libraries, which are used by the web container to render the page.
A minimal example of a web application using JSP can be seen in this link.
Install a Tomcat:
With Tomcat installed you can start JSP development. To start the development you must create an easyjava directory in C:\Program Files(x86) \ Apache Software Foundation\Tomcat 7.0 \ webapps (on Windows) and/usr / java / apache-tomcat-7.0 (on Linux)".
Save the file and open the browser of your choice and type: http://127.0.0.1:8080/easyjava/ola.jsp , as shown 1.