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.
Related
I have an application programmed in classic asp. Now I need to create a new function that is accessible by all the files of my application, the problem is that I would have to add includes for all sites.
Does anyone know how to define this function globally without the need to add the includes?
I have already tried with global.asa but it did not work for me.
Thank you very much in advance.
a greeting
I don't believe there is a way to create an ASP function that can be called from any ASP file without including the function in the ASP page that needs to call it.
A common design pattern I use for a site (or a folder of related functionality within a site) is to create a file that contains this kind of thing -- global functions -- then include that file in every ASP file on the site/folder. One common thing this file might contain is a subroutine that emits the initial HTML before the content of the page, and another that emits everything that comes after the content. This allows me to easily give all pages a common appearance and (when combined with a common style sheet) to change that appearance without modifying each page. You can also include widely referenced functions in this file. For example, every page on my site has a login form at the top. The code to handle validating a customer's login credentials is in this global header file.
I'm starting with web development these days and I would prefer so called client side rendering. In practice that ajax request needed data and add them to the html file ( which has already the static content, and dynamic data is added via 2nd request ). I like this approach, cause of a clean seperation between client and server. You just need to define an API and you can seperate the work.
So if you don't create the dynamic content on server side, how dou you persist data between page requests.
For example, you are on a overview for a list of adresses. You can click a button to edit a specific adress with id "25". That will requiere a new html file for that task, which will be loaded and rendered. How does the javascript included in that html file know, which adress should be loaded. How can it access the id "25"?
Approach 1. You don't persist anything on the client and simply reload everything as you go back and forth between the list page and the editor page. Editor page gets the id "25" and loads corresponding item either using AJAX, as you want, or on the server.
Approach 2. You do everything on the same page (SPA). You use JavaScript and probably some framework like Angular to maintain your page state.
I am currently developing a customized template of SquareSpace and I am not sure how to view the changes i have done locally? Also are there any resources out there to help me alter the templates, the documentation on the site isnt great?
Being able to develop and then display rendered squarespace (SS) templates in a local development environment (or "offline") seems to be an oft requested feature.
It's not straightforward so far as I can tell. To quote
The short answer is no. There is not currently a way to develop locally.
However, once we get site data exports working it should be a simple matter to setup a lightweight node js script to get local development running.
(source), similar answers
According to the SS docs, the templating engine is JSON Template, the styling is done by LESS and all of the data for a website is stored as JSON. The data for any page of an SS website can be viewed by appending ?format=json-pretty to the URL of the page (or &format=json-pretty if the URL already has a query string appended to it).
Here's an example of how to use the javascript version of JSON Template to render a template (view its source).
So it should be possible to set-up a local devenv. The solution would have to combine the use of the aforementioned components along with a way to combine a set of templates for any given page (e.g. combine sites.region and collections/blog.list for a blog index page). You could probably even hack together an html page along the lines of the aforementioned JSON Template example without the ability to combine templates if you just wanted to develop within a single template.
I want to know whether any problem or load on the server when a big static html file is included in JSP.
Whether the server takes load in including the file on startup. I know that server converts and compiles the jsp only once on startup. And the page is rendered directly as servlet whenever user hits it.
I had a debate with my manager on this. Can you please provide me some information on this. I need Pros and Cons by doing this (server load / client load / anything related).
java translates jsp content into a class, which basically acts like this:
JSP file with content such as:
<div>this is regular html</div>
<%
System.out.println("this is code");
%>
is translated into:
out.println("<div>this is regular html</div>");
System.out.println("this is code");
where out is the response output stream.
so all your static content will be translated into such response out function calls, which technically is probably a bit slower than just sending the whole file back in one big chunk.
There's also the possibility of caching on the client side when static content is used, something you can't do when you embed dynamic data in there. You can also serve it from a CDN network instead of serving it directly from your app servers.
And last, you can serve all your static data from a web server and your dynamic data from your app server if this is the way your system is set up, which might make some sense.
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.