In page.html we can use javascript code, I accept that, but can we use jsp and tld files in html files.
Please explain.
Any server-side code would need to be executed on the server, not in the browser. There's a hard separation between the server-side processing and the client-side processing. So the JSP code wouldn't be able to interact with the JavaScript code or anything like that.
In order for server-side code to be executed in an HTML file before rendering it to the browser, your server would need to be configured to process that code. It would be a matter of configuring your web server, whichever one you're using. By default I imagine it just returns .html files to the browser without any server-side processing. But you can configure your web server to treat .html files just like it would JSP files.
Keep in mind that you would need to treat those .html files like you normally would JSP files. It would have to match the same conventions for separating client-side code from server-side code.
If you configure your web server to map the text/html content type to JSP, you can.
No. JSP pages are executed on the server side and produce HTML, which is sent to the browser. JSP acts just like PHP in this regard, essentially "rendering" some HTML code and sending it off to the user. You can't embed JSP code in the HTML and send it off to the user - their browser will just do nothing with it.
Related
I want to show list of all files from web server or a directory from web server into my WEB page using HTML.
I searched google a lot but didn't find anything.
Any suggestions?
Possibility 1) activate DirectoryBrowsing [aka DirectoryListing] (Apache, IIS and probably all others support this).
Possibility 2) use PHP, JSP, ASP or whatever language to make a list of the files.
HTML itself is just a markup language, so there's no possibility to do that with HTML only.
recently i have been trying to so make a contact form work and i finally did after hours of struggle.
http://trulyamped.com/democon/contact2.php
This contact form works perfectly and the email gets sent to my account.
The only thing i wanted to know was how do i make the contact form work in an .html file. I do not want it to be in a .php file. I already tried to save the file as an .html file but it did not work. Please let me know.
so pretty much i want it to be contact2.html and still be able to work.
First of all, why does it matter?
But assuming for a moment that it does matter, you probably have a couple of options. They depend on where your code resides and what it currently does. If the page has PHP code that needs to execute server-side then it needs to be processed by the PHP interpreter server-side. To do that with an HTML file you'd need to configure the server to treat .html files just like .php files for server-side processing. This isn't ideal, though. HTML by itself doesn't need to be run through the PHP interpreter. So it's best to keep the PHP and HTML files separate.
Another option could simply be to separate the client-side HTML form and the server-side PHP code into two separate files. Something like contact.html and contactProcessor.php. In the HTML file you'd just post to the PHP file in the form. Something like this:
<form action="contactProcessor.php" method="post">
This would cause the form to post the data to the PHP file. Then the PHP file can process the data, do whatever you're currently doing server-side, and redirect the user to another HTML file as a response. So at no point would the user be "viewing" a PHP file. There's just be one used to handle the form post.
Again, I can't imagine why it matters though.
You would need to create a 2nd page that only has the email processing logic, let's call that email.php you could then update your form to post to email.php and change this page to be contact2.html as long as it posts to a .php file it will work.
<form id="contact-us" action="email.php" method="post">
Your bet is to use AJAX for the main form but will still need a server side script page to handle the mail sending. As far as I know, it's not possible to send mails from the client side.
So
Have the PHP page that actually sends the mail in a separate script file
Create your form in HTML and use AJAX to call the mail sending script from within your HTML page.
This way you can have your page in html and do the mail sending at the background.
Regarding saving your page with .html extension, of course it wouldn't work. Because your page contains PHP which is server-side and needs a web server to run, while html can be run on any simple browser on any device.
Given a simple HTML file is there any difference when testing, in opening it directly by double clicking it or uploading to IIS/Tomcat and accessing localhost/simpleHTML?
In the case of html files it dosenot matter much. Where this matters is when the page is made in languages like php, jsp etc. A webpage containing php or jsp files will not be detected by browsers when directly opened. For this we use webservers like wamp, xampp, lamp, tomcat etc and acces it via localhost/pagename. For more details just view the pagesource of a php file. You wont be able to find and php scripts in it. You will be able to see only the html part in the page. For scripting languages like html, javascript, css etc. opening directly dosent matter.
Hope this is useful to you.
No, a simple HTML-only file will not be rendered differently most(99.9%) of the time by opening it directly by double-clicking from the local file system and accessing it from a web server. The only difference will be caused if the file contains any server side language (PHP, ASP etc..)
I have tried every possible question here on stackoverflow but unable to resolve this issue ...
<!--#include virtual="include.shtml"-->
<!--#include virtual="include.html"-->
<!--#include file="include.shtml"-->
<!--#include file="include.html"-->
<!--#include virtual="/include.shtml"-->
<!--#include virtual="/include.html"-->
<!--#include file="/include.shtml"-->
<!--#include file="/include.html"-->
<? include("/include.shtml"); ?>
<? include("include.shtml"); ?>
<? include("/include.html"); ?>
<? include("include.html"); ?>
I tried with apache server running at localhost/include/index.html or file:///home/sahil/Desktop/include/index.html with all above includes but none of them is working for me :( .Now which method should i use to include one HTML file into another , considering my index.html and include.html both are in same directory ???
The former syntax is SSI, the latter is PHP. Both are server technologies and will only work if accessed from an HTTP server that supports and is configured to check the file for the syntax (which usually means you have to turn the support on and use a .shtml/.php file extension (or change the config from the default to determining which files to check)). Other server side technologies are available.
The only "include" mechanisms in HTML itself are (i)frames and objects.
You could also consider a template system such as TT that you could run as a build step to generate static HTML documents (NB: TT can also be used on the fly).
HTML is Static
It is not possible to include a HTML page within another HTML page with static HTML because it is simply not supported by HTML. To make your HTML dynamic, you have 2 possibilities: use a client side script or use a server side technology.
...Unless you start using frames (dropped with the HTML5 standard) or iframes that are most likely not a solution because of the fact that it is treated as a completely different web page.
Client Solution
You could create a JavaScript file and write your HTML with the document.write function and then include the JavaScript file where ever you need it. Also, you could use some AJAX for this, but there are JavaScript libraries out there that could ease your burden such as the popular jQuery library.
Yet, I would not suggest using a client solution because it is more trouble than it is worth...
Server Solution
There are many server side solutions out there: ASP, ASP.NET, ASP.NET MVC, Java, PHP, Ruby and the list goes on. What you need to understand is that a server a side technology could be described as a parser for a specific server side language to automate certain tedious tasks and to perform actions that would represent a security risk on the client.
Of course you will need to have the means to host such a site and to configure the hosting environment. For example, you could host a PHP website with Apache and even have a developer hosting environment such as /MAMP/LAMP/WAMP.
You can view an example of including a page in PHP in the online documentation.
Personally, I would be more inclined to use a server side solution.
HTML doesn't have an 'include' mechanism - I'm not sure where you've seen these solutions on StackOverflow. You've probably been looking at answers for a server side language such as PHP or ASP.
You do have the following options for 'pure' HTML where you only have static pages and JavaScript:
Frames
Ajax
See my answer here for sample code and more details (and also a caveat about SEO if that matters to you).
Make your html file you want to include to php file. (only change the extension - to .php). If the files are in one directory, include code is:
<?php include "nameoffile.php" ?>
I have some static websites. By static I mean all the pages are simple HTML without JavaScript (all the data are hard-coded).
I have a server side program that creates dynamic data that I'd like to insert into my static sites. By dynamic I mean the data changes very often.
How should I do this?
Here is a scenario: On the server side my program generates the current time-stamp in every millisecond. When a user open one of my static sites the page gets the current time-stamp from the server and render it.
I'd like it to work with search engines, so I can't use JavaScript.
It's not possible to change the HTML structure client side without Javascript, so your solution is to add some handler server side for files with .htm and .html extensions.
About JS: Please note that most spiders (if not all) won't be able to see data rendered by javascript since most of them are analyzing the plain HTML that is returned by the server.