XML: rendered as an HTML file in URL - html

I've been given the task of rendering an xml file via xsl as html. This means it appears as /.../index.xml in the URL.
However, the task requests that the xml file renders in the URL at /.../index.html.
Currently it renders as index.xml not .html - how do I achieve this?
Any ideas/resources would be great, thanks.

One simple way to satisfy the requirement (there are others, no doubt) is to configure your server to redirect index.html to index.xml. How you do that depends on which Web server you are using; consult the documentation for your server. If you're using Apache, you will want to read up on .htaccess files and redirection.

Related

How to host website on github with HTML and CSS preprocessor format?

I have created a new repository and and included all files necessary to host a website on github, see (https://github.com/tonystaark/tonystaark.github.io/tree/master)
However, I received a 404 error when I visited my own website at tonystaark.github.io. The error says that 'For root URLs (like http://example.com/) you must provide an index.html file.'
How do I convert my .pug format into a html (or .postcss into a .css) file then?
You can easily generate html from pug file using command line option,
pug -O '{"doctype": "html"}' index.pug
It's automatically generate index.html file for you.You can check other options from here
Pug files need to be compiled onto the server before being served as an HTML file. There aren't many great ways to compile Pug in the client. If you have a strong need to use Pug as a templating engine, GitHub Pages will not be able to do that. You will need to host your site somewhere that supports Node.js engines (Heroku, DigitalOcean, Amazon S3, etc.)
I didn't see any Pug files in your GitHub repo, though, so I don't know if you figured out another solution or tried to do something else.

java server pages and html

From what I understand a jsp is responsible for dynamically generating html pages, which are later sent to the client browser for viewing. But then why do browsers show a .jsp extension while viewing some pages? Is it possible to view a .jsp file in a browser?
But then why do browsers show a .jsp extension while viewing some pages?
Because, traditionally, JSP files have .jsp file extensions, and URLs map directly onto files on a filesystem (these days the front controller pattern means you see less of that).
Is it possible to view a .jsp file in a browser?
Not an arbitrary one. Servers execute server side programs and return the output to the client, not the program itself.
You need to have a server to view jsp files. I think you can find your answer here

how to embed pdf file in html with security?

I am using below code to display pdf file in HTML
<object data="data/file.pdf" type="application/pdf" width="300" height="200">
test.pdf
</object>
But In above code we have to specify path name and folder name so it is not so secure. Crawler can find this path, so using some algorithms(robot) it is very easy to download other file those are stored in that folder.
How to secure this, is there any option to prevent this from robots?.
You may do the following:
Password protect the page (with the server-side code).
Generate unique links like (/getpdf/some_random_string_or_md5_hash_of_random_string.pdf) for every PDF file (using server-side code) that will a) check for the current time and the validity of the random name generated (if it has expired or not) then b) will redirect to the source files (not really hiding the source because of the redirection) to be displayed or stream the PDF file content (this is more secure though could seriously add the load to the server).
Finally add robots.txt to the folder and hope that crawlers will follow restrictions it sets.
If the other files in the directory are not to be downloaded, ever, they shouldn't be in a directory that is available to the http server. You can use directory permissions in your http server (eg., config directives and .htaccess in Apache) to control access to directories. Only configure access for directories you need to expose to the web, and only store files in them that you want the web to access.
If you want to avoid including a path in the HTML, you will need to write some dynamic code (eg, php, asp, or any number of server-side options). Your code on the server would need to handle the request for the file and return the file's content manually.

Can i put a .doc or .txt for displaying data in html

I just wonder if i can put a .doc or .txt files in the html instead of placing too much code in showing the data. I think that should be some method but i m not sure about it
You can put a direct URL to a .doc or .txt file on your server without even using HTML if that's most convenient. A browser will typically display .txt files right in the browser itself. A .doc file would likely be offered to store on disk so you can use a program like Word to view it.
If you are talking about embedding data into an existing HTML page there are ways to do so but it would require knowing more about your server. Are you using PHP to respond to requests?
You can use a number of methods to acheive this. Most commonly used are php includes if the server is capable of executing php scripts. Javascript is also commonly used and there are many examples of how to do this. This could also be achieved using SSI (server side include) but this method is not commonly used and requires renaming the file with .shtml extension
Hope this helps.

Using filepath as a hyperlink in HTML

I Wonder whether I can use pdf Source[as hyperlink] as a file path in system related to script's running directory.
part of code is.
pdf
I am generating this HTML using CGI Scripting in C. and my pdfs are located in ../pdfs/sample.pdf related to my running directory of script. And by pdf source means I want to show the pdf sample.pdf upon clicking pdf as in above sample code.
A browser does not care or know how a resource is generated. You can generate it with C via CGI, you can have the server just hand over a static file. There is no difference as far as the browser is concerned, it made an HTTP request and received an HTTP response.
The rules for resolving a relative URI in an HTML document are the same. The browser compares it to the base URI (which is either specified in <base> or is the URI of the document containing the link).
If that resolves to a URI that the server will serve a PDF up for, then it will work.
Since URIs don't always map directly onto file systems, it isn't possible to say if this will work in your situation (as your question only talks about file systems). If this was on one of the servers that I have CGI programmes executing on then it wouldn't work — since I keep them in a cgi-bin that isn't a subdirectory of the webroot, so the pdfs wouldn't be accessible over HTTP at all. Your server may be configured differently.