6

I am using Netbeans and MySql server. I want to add JSP content into an HTML file. How can I include it?

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
Parth Joshi
  • 63
  • 1
  • 1
  • 4

2 Answers2

7

Make the HTML file a JSP page, and use a JSP include (static or dynamic, depending on what you want, but you probably want a static include here):

<%@include file="theJspToInclude.jsp" %>

HTML files are static resources that are served as is, without any kind of interpretation, by the web container.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
  • the thing is that i want to keep the html file instead of jsp bcoz the jsp page creates a session which makes difficult to invalide taht session in next page so it will be good to keep html file and including jsp file in it,,so can i do it? – Parth Joshi Apr 08 '13 at 16:16
  • 1
    use <%@ page contentType="text/html;charset=UTF-8" language="java" session="false" %> It will not create session – Dev Jan 01 '14 at 06:03
5

JSP is a dynamic one. It needs a web container to get executed. Why do you need to include it in a static html page. To my knowledge, if you want to include a jsp page in a html page, then your page is intended to be dynamic. So you have to change that to be a JSP page. Now you can use

<%@include file="includeable.jsp" %>

This will include your jsp.

You cannot include a JSP to a HTML page.

Rengasami Ramanujam
  • 1,858
  • 4
  • 19
  • 29