why sometimes jsp is used instead of html for user interface? - html

I have a project that I am working on Spring MVC. The project uses jsp instead of html in my view for the front end UI. Can you please tell me why jsp is being used and not HTML. Is there any special purpose for using .jsp files instead of .html in Spring MVC. Can't I use html and Javascript to achieve the same functionality?
I understand this is a basic question but I dont have any experience in web development, I have just started working in a company and they want me to work on this. I have tried looking for comparisons, but there are a lot of comparison between jsp and servlets online but I cant find anything which tells why jsp is used instead of HTML pages. This might be very obvious to you but its not to me. Any hints, links, description is appreciated.

From my experience below are the reason of using jsp or more in general a template language for rendering view.
HTML can not read request data as it actually don't know what is request / session data and it has nothing to do with it actually. On the other hand, jsp knows request, response, session etc.
when you need to generate your content dynamically you may use loops and other logical stuff available but how will you do that in html? Your answer could be using javascript but it would be more problematic.
HTML is statically typed and is parsed at browser i.e. client side and hence would be evaluated at client side which exposes your page and would allow client to do several manipulations. But JSPs are server side and hence are more secure and safe as client can only access html in last.
Last but not least Java knows JSP but not html and hence for developers using JSP is better as they easily do good manipulations which a UI dev can't do .
Hope it helps!

Related

In HTML, is there a way to find out if a particular string is variable?

Let's say I'm looking at a webpage that has a title including the year, such as "StackOverflow 2016". Is there a way, by inspecting the page source, to find out is this string is variable (function automatically updates it every year), or if it is a hardcoded string?
HTML is for navigator and is the result of a php (or python, etc.) script, so no you can't. (But you can if it is powered by javascript)
There is no way, unless the web site has been specifically coded to make that possible.
I know of one website that does enable marking the variables in its output, but even then, this functionality is turned off for most page requests – it doesn't work unless you explicitly turn it on for that request.
Certainly, there is no standard way in html to notice this.
If it is a string variable it is inserted when the page gets created, so to tell if it's hard coded or not you would have to have access to the file which constructs the page - usually a template or a PHP file, etc.. So no, you can't tell if it was a variable or a plain text just from inspecting the source on the client's side.
With one word: No, you can't...
Different scenarios:
By looking at the HTML alone... no, there is no way. Unless, in your specific case, you refresh the page at NYE or something like that... which is silly.
In the HTML is processed on the server.. there is still no way you can know if it is a hardcoded string or a variable.
There might be a chance to see that by looking at front-end source code if the HTML is processed in the client-side of the app...
You have to undestand that the web page you see is often generated by code that resides on a server, potentially miles away from you. When you ask for a web page you get simply an HTML page, no more.
So, generally, all the methods that generates the data you see on the page cannot be seen client side. Try to imagine what could happen if, let's say, StackOverflow would give you the "power" to see the logic the exists behind web pages of the entire app. You could use these information to do a lot of damage or to steal informations or complex algoritms.
I've said generally because data on web page could be generated by javascript, a client side language that can be used to modify the DOM.
In this case you could see if your string is update by a function.
As far as I'm aware there would be no way to know this as the source you can see will be what is rendered. So there will be no way to know if this was added with php or js etc.

Finding out how a website is coded

I'm trying to figure out how to program a website that looks very similar to http://www.renthop.com/.
I'm new to web coding, so I'm not really sure where to start. For example, is it Java or HTML? Or both? I really like how its setup, the responsiveness and smoothness of it. I just want to make sure I start off in the right direction in terms of choosing the right language etc.
If anyone has any idea of what this is based on it would be greatly appreciated!
Thanks - KC
The server-side code is PHP, the front-end is built off of the jQuery and jQuery-UI javascript libraries and a series of third-party plugins. The final product is a dynamic HTML application.
Do you want to launch your website? If so, creating a website from HTML would only make a website on your local hard drive, not public. You're going to need a domain name and hosting to make it public.
HTML is a markup language for formatting websites, but you can still create a website out of it. Not public, as I said above.
CSS is rulesets for telling the browser how to display the HTML formatted content. It is also not a programming language in the same way HTML is, although it can be a lot more powerful.
Javascript is a programming language. You use it to make the website interactive. Get Firebug or a similar add-on for Firefox, or just right click and 'Inspect Element' in Chrome to see the javascript for more detail on what javascript does.
AJAX is an extension of javascript to get data from the web server and update the page with it, without having to refresh the page.
PHP is code commonly used server side to interact with the filesystem and databases and output HTML. You can also use python, perl, .NET and a handful of other languages/frameworks to do this.
MySQL is a database.

How to internationalize html pages

Is there a way to internationalization html pages based on user locale?
I had a website developed using html pages but now I am asked to internationalize that website in 4 different languages.
I know how to do it using Spring Framework via resource bundles but I wanted to know if there is a way to do something similar using HTML pages so that you just have to write the code considering internationalization and just keep adding the resource bundles to be picked based on user locale when a user accesses the website?
I've just developed a solution a little bit lighter, using CSS content property :
https://github.com/k-yak/stati18n
Take a look, all informations are available in the readme file.
How about this?
http://code.google.com/p/jquery-i18n-properties/
Or How about this?
How does internationalization work in JavaScript?
If you can't do Javascript you'll have to use some form of templating or dispatching. That is either respectively:
Use JSP and Spring's Message taglib (or any other templating language that supports i18n)
For each locale you would copy all the HTML pages in a locale directory and then dispatch to the directory based on the locale (I don't recommend this).
What I personally do is use jMustache which is barely a templating language and then for each page (or many pages) I will have request controller that will load all the translations for the request locale into a Map object which I feed to jMustache (see Option 2 of my answer here: https://stackoverflow.com/a/10004113/318174).
If you keep your site static, you'll end up having multiple copies of your site, unless you can dynamically modify the page using javascript. But, you'll also want the URL's to have the language code in them to save state and be good for SEO.
I developed this free solution. http://www.sitetran.com/

How to Create Global Header for all pages in html(5)?

I have created an HTML page 'header.html'. Then I need to implement the same header on about, services, contact page.
I know that we can do it via PHP Include. But as an HTML Developer, Is there any way to use like this in HTML without using third party code, especially in HTML 5?
Also I came to know that Dreamweaver has an option to make templates file. But I don't know is it valid in Web 3.0 and W3c.
Please Help me.
You need either a server-side language like PHP or Server Side Includes, or you use something like Dreamweaver which will assemble HTML files for you from parts which you then upload to the server. You cannot do it browser-side using HTML only.

How to upload a file to a website using HTML

I'm developing a website and I'd like the users be able to upload files to the server using a webpage.
The server side is .NET, but it's not ASP.NET. That means, I'm generating the html code myself instead using ASP.NET, and I'm working with the GET string and POST stream directly. It's a good exercise to learn what happens under the hood :D, specially nowadays when there is a framework for everything.
I've been trying to find information about this, but I found several approaches, some of them javascript (thing I want to avoid for the time being) and lots of premade controls. What I want is to do it myself, I don't care if there is a nice, nifty and well-proven ASP.NET control... what I want is understand how it do that with all its implications.
Cheers!
In the HTML you need a form with an input of type="file" and the enctype attribute of the form set to "multipart/form-data" rather than the default of "application/x-www-form-urlencoded".
Multipart/form-data is defined in RFC 2388, and will behave differently to the application/x-www-form-urlencoded you've been parsing with this experiment so far, though it's quite straight-forward. The RFC should give you all you need to know to replicate how the HttpRequest.Files property works in ASP.NET.
An extension of this, try sending streams from XMLHttpRequest in a page or HttpWebRequest in a .NET client application, using both POST and PUT (you may have to change IIS settings to allow the PUT through), as this the overlap of working on that along with your experiments here will cover some knowledge that has some real applicability even when you are using all the toolkits. Another extension is to try implementing both sides of both schemes in RFC2617 without any help from the framework (sometimes the server side of this is genuinely useful).
Kudos for experimenting with this, it should bring real experience to back up what you can learn from reading RFC 2616 (though that's still absolutely vital for anyone doing web stuff to be intimiately familiar with, as reading will cover some cases your experiments don't touch on, and explain anything that seems strange in your results).
I think this should have what you need.
Basically you need an <input type="file"> and to set the encoding of your form to multipart/form-data.
<input type="file" name="somename" size="n">
You put that in a form, and hasta la vista baby !
You can't do a file upload using pure HTML: You will need to handle the uploaded files on server side.
You could parse the uploaded file(s) out of the raw POST data if you want to learn how it works "under the hood" (see here for an example how to do it in ASP), but you will need some kind of server side language to do it.