How can I call JSP Page through HTML? [message #259213] |
Tue, 14 August 2007 12:14 |
harleenflora
Messages: 44 Registered: June 2006
|
Member |
|
|
I have created a website in JSP. I am using include files for header, footer, leftnav and rightnav on each page.
But in order to launch the website my first page should be index.html instead of index.jsp.
Any ideas how can I call JSP Page through HTML?
Please let me know.
Thanks!
|
|
|
Re: How can I call JSP Page through HTML? [message #260340 is a reply to message #259213] |
Sat, 18 August 2007 12:24 |
kmmfoo
Messages: 38 Registered: June 2005 Location: massachusetts
|
Member |
|
|
The best approach would be to change the behavior of your site so that it includes index.jsp as one of the default files. Typically that is done using the upper-level control files of the site. Here's a link from Sun that describes their approach.
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/WebApp4.html
Actually, you don't say what type of webserver you're using, so it's really hard to guess. But if you were using an Apache webserver, you might want to review the "DirectoryIndex" directive here...
http://httpd.apache.org/docs/2.2/mod/mod_dir.html
In fact, if you were using Apache and _didn't_ want to do that, you could do a redirect to another page using the "redirect" directive in the webserver control files as described here:
http://httpd.apache.org/docs/2.1/en/mod/mod_alias.html#redirect
However, if you were unable or unwilling to do any of those, a cheap hack workaround (that is frowned upon by civilized people) would be to create a very small file called "index.html" and inside that file put a META tag that sends people to your "index.jsp" file. For more info on META tags, you can search the web. For a simple example,
<META HTTP-EQUIV="Refresh" CONTENT="0;URL=http://www.mysite.com/index.jsp">
<html>
<body>
you are being redirected please stand by
</body>
</html>
The "0" in the META tag is the number of seconds it will wait before redirecting -- in this case zero seconds.
HTH...
|
|
|
Re: How can I call JSP Page through HTML? [message #261056 is a reply to message #260340] |
Tue, 21 August 2007 11:59 |
harleenflora
Messages: 44 Registered: June 2006
|
Member |
|
|
Thanks for your reply.
I have put a META tag in "index.html" which redirects to "index.jsp" file.
I created my website using Jdeveloper. Network Solutions is hosting my website and according to them they support jsp page.
index.jsp page has include files (.inc) for
- header - header.inc
- footer - footer.inc
- leftnav - leftnav.inc
- rightnav - rightnav.inc
index.html is redirecting to index.jsp page but it doesn't display contents from include files.
Any ideas why this is happening?
Everything works when I run it on my local using Jdeveloper but on when I ftp it.
My Web Server has two default folders - cgi-bin and htdocs.
All my jsp, inc, jpg files are under htdocs folder and following are my files.
Index.html
<META HTTP-EQUIV="Refresh" CONTENT="0;URL=http://www.mysite.com/index.jsp">
<html>
<body>
you are being redirected please stand by
</body>
</html>
index.jsp
<html>
<body>
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td>
<jsp:include page="header.inc" flush="true" />
</td>
</tr>
<tr>
<td>
<table cellspacing="0" cellpadding="2" border="0" width="100%">
<tr>
<!-- Left Nav -->
<td width="21%" valign="top">
<jsp:include page="leftnav.inc" flush="true" />
</td>
<!-- Main -->
<td width="58%" valign="top">
<table cellspacing="2" cellpadding="3" border="1" width="100%">
<tr>
<td> </td>
</tr>
</table>
</td>
<!-- Right Nav -->
<td width="21%" valign="top">
<jsp:include page="rightnav.inc" flush="true" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<jsp:include page="footer.inc" flush="true"/>
</td>
</tr>
</table>
</body>
</html>
header.inc
<html>
<BODY>
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td width="10%">
<DIV align="center">
<img src="mylogo.jpg" height="100" width="550">
</DIV>
</td>
</tr>
</table>
</body>
</html>
Please help me with this.
Thanks.
|
|
|
Re: How can I call JSP Page through HTML? [message #261092 is a reply to message #261056] |
Tue, 21 August 2007 15:37 |
kmmfoo
Messages: 38 Registered: June 2005 Location: massachusetts
|
Member |
|
|
Sorry, I don't know nothing about jsp:include files, but it seems to me that if you're trying to "include" header.inc inside another HTML page, you shouldn't be duplicating the HTML and BODY tags.
Also, since you're not using dynamic content, perhaps you might want to consider the simpler syntax
<%@ include file="header.inc" %>
But whatever, like I said, I don't know nothing about jsp:include files.
|
|
|