How to include HTML in JSP?

html, java, jsp

Solution

I would like to show you a way, try like below. You can try with else instead with `if`.

<body>
        <%
            int x = 10;
            if(x>10) {
        %>
        <%@include  file="some.html" %>
        <%
            }
        %>

</body>

Problem

I've searched for this question, there are some answers, but not exactly as my question. So, here is my jsp code: ``` <body> <% if (manager.isValid(request.getParameter("username"),request.getParameter("password"))){ out.print("<h1> Welcome "); out.print(request.getParameter("username") + "</h1>"); } else { out.print("<h1> Please Try Again </h1> <br />"); out.print("Either your username or password is incorrect. Please Try again <br /> <br />"); } %> <%@ include file="LoginForm.html" %> ``` but instead of this, I want to include "loginForm.html" only in "else" block. How can I do it? Of course this doesn't work, but you'll guess what I want: ``` <% if (manager.isValid(request.getParameter("username"),request.getParameter("password"))){ out.print("<h1> Welcome "); out.print(request.getParameter("username") + "</h1>"); } else { out.print("<h1> Please Try Again </h1> <br />"); out.print("Either your username or password is incorrect. Please Try again <br /> <br />"); include file="LoginForm.html" ; } %> ```

Original source