Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
How do I incorperate code into HTML?
So I've gotten used to writing HTML, but I don't understand how to make a website work with actual programming code, and do stuff like store data, process inputs, and basically anything else a computer program can do. Is a tutorial for this anywhere on the internet?
5 Answers
- JaredLv 79 years agoFavorite Answer
There are two "simple" things you can do:
1) Javascript (actually that's fairly simple). This is "client-side" programming because you merely give the javascript to the client's web browser and the browser is responsible for running the code...I wouldn't consider javascript "actual programming code" though.
2) JSP (Java Server Pages). Here you can embed java code in an HTML document. This would be considered "server side" programming.
The problem with JSP's is that they aren't nearly as simple as anyone makes them out to be. It helps a little to understand how a JSP works:
What happens with a JSP is that your web-server parses the .jsp page which will look, for the most part, like a normal HTML page, except that it will have Java code sprinkled in. The web-server finds those bits, converts the page to a servlet, then when a client makes a request for the web page, the servlet is called...OK, so what does that mean?
What it actually means, is that the .jsp page is used to generate Java code, which, in turn, is generally used to generate "dynamic" content (i.e. content that might change everytime the client requests the page).
For instance, you can write a JSP to display the current time...the code might look something like this:
<body>
<h1><%= System.currentTimeMilli() %></h1>
</body>
So what happens, is that when a request is made to the web server, it will call this function, get the String value, then generate an HTML page that has that info in it...so if you were to look at the source returned by such a request, it would look like this:
<body>
<h1>654321987654</h1>
</body>
So, to the client, it doesn't even appear like anything special happened, it just looks like a normal HTML page...and that's because that's EXACTLY what JSPs offer, they offer a way of dynamically generating HTML pages (using Java code).
So what's the catch? The catch is that you HAVE TO HAVE A WEB-SERVER capable of handling/translating JSP pages. Furthermore, you have to know HOW to use this function with your web-server.
Google: "JSP tutorial" for further info
(notice that you will also need to know what web-server you are using and will have to find the documentation on how to use JSP with your web-server)
Edit:
If you want to see how to write your own web-server, then you can check out my tutorial on creating a web-server in Java using the HttpServer class:
http://bennatt.no-ip.org/jwserver
(if the link is dead it means my computer must have shut down and I haven't restarted my server).
I don't really explain anything all that interesting unfortunately, but using what I did, you can easily encorporate custom content if you understand the HttpExchange process (i.e. the HTTP protocol). For instance, I have an applet which is capable of reading a picture from your computer, which, generally speaking SHOULD be impossible with an Applet.
But because I actually have you upload the picture to my server (which it turns out is fairly difficult), then I dynamically generate an html page which has the Applet embedded in it AND I give the Applet a parameter which points to the URL of the picture you just uploaded.
http://bennatt.no-ip.org/picture.html
So if you look at the source after you upload the picture you will see where I dynmically generated the URL...this is essentially the same thing that a web-server would do with JSPs.
- LocoluisLv 79 years ago
You don't. HTML is a static document format.
What you do is to make a program that outputs an HTML page. A clean and easy way to do it is by making a template HTML page, which will be filled with data from the program.
The most popular programming language for making such programs in the server side is PHP, whereas in the client side the standard is Javascript. If you want to save data to permanent storage, you can only do it on the server side.
Server side? Yes, you need to upload your PHP program to a web server and run it there (by making a request to its URL). The result will be HTML code that will get displayed by your web browser.
You have a lot to learn.
- 9 years ago
Google "client side" and "server side" to get a better understanding of what you are asking. But then take a look at javascript (NOT java) as it can do some pretty cool stuff in client side html pages.
- 9 years ago
If u want to build a website please tell me what kind and I'll help you my YouTube channel is SketchZzx
Source(s): Youtubev - How do you think about the answers? You can sign in to vote the answer.