How to use a file . JSP

Asked

Viewed 870 times

1

I am extremely new in JSP language, I wanted to know how to use a jsp file that I created and display for example in the browser, the same way I do with html files, ie how to use a jsp file created??? Obs: in the image attached 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>

inserir a descrição da imagem aqui

  • You have to set up a Web Container, an example of Tomcat. Another thing since you’re starting out, look for more about JSF. On youtube you have many lessons for beginners in JSP, JSF, in which you can learn how to set up a server and run your first page with Java technology

2 answers

2


You cannot open a JSP file directly in the browser as it is an "above" HTML language. 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 to identify these components, which is why you need your JSP-containing project to include libraries jsp-api and jstl, that are used by the web container to render the page.

A minimal example of web application using JSP can be seen in this link.

0

Install the Tomcat :

http://tomcat.apache.org

With Tomcat installed you can start JSP development. To start 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 preference and type: http://127.0.0.1:8080/easyjava/ola.jsp, according to Figure 1.

Figura 1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.