Including Static html and js pages

Including Static html and js pages,
Getting the host name in static html and js file
Getting the static html and js file in jsp pages
*****************************************************************************
//adding the js code in html.this is html file
<script src=”*.js” language=”javascript”> </script>
<script src=”*.css” language=”javascript”> </script>
<script language=”javascript”>
var hostName=window.location.hostname;
</script>

//using below code to write the html code in js file
var hostName=window.location.hostname;
document.write(‘<link href=”‘+hostName+’/styles/default.css” rel=”stylesheet” type=”text/css” />’);
document.write(‘<div><a href=”http://’+hostName+’/about-us.html” title=”About Us” >About Us</a></div>’);

//Dynamically getting the code server side then we have add it in html page
<script>document.write(“<a class=’links’ href=http://”+hostName+”/affiliates/affiliate.xgi?method=loadJoinNow>  <img src=’http://”+hostName+”/images/laydef_03.gif’ alt=” width=’124′ height=’88′ border=’0′></a>”);</script>
<script>document.write(“<a class=’links’ href=http://”+hostName+”/affiliates/affiliate.xgi?method=loadJoinNow>  <img src=’http://”+hostName+”/images/laydef_03.gif’ alt=” width=’124′ height=’88′ border=’0′></a>”);</script>

//Reading static html file from apache server in js page

<script type=’text/javascript’ src=”<c:out value=’${staticUrl}’/>/header.js”></script>     //staticUrl is apache server ip   ex:http://192.168.10.217:80

//Reading static html file from apache server in jsp page

<%
String linksName=(String)session.getAttribute(“staticHtmlPath”);   //staticHtmlPath is apache server path ex:C:\\Apache2.2\\htdocs\\earnreal\\
File filelinks = new File(linksName+”index.html”);
FileInputStream fislinks = null;
BufferedInputStream bislinks = null;
DataInputStream dislinks = null;
try {
fislinks = new FileInputStream(filelinks);
bislinks = new BufferedInputStream(fislinks);
dislinks = new DataInputStream(bislinks);
while (dislinks.available() != 0) {
out.println(dislinks.readLine());
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
%>

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.