Event-driven Web Tour - JSP and JavaScript
(This document gives all programmers using Delphi)
Before the topic, I will write a order first!
I love Delphi deeply, I can't extricate themselves. But I also saw that B / S is the big direction of future programming, and I have more Delphi for many years, so that I choose Java / JSP at this time (do you know? The first thing you try cross-platform is pASCAL). To tell the truth, Delphi is well deserved in the Windows desktop development field. He is so fast and convenient. When you learn the web, I also brought it into Delphi's idea. Why is Web not aspects like Windows Application? Based on event-driven, the state is automatically maintained (this is actually Windows idea). However, learning the web development only knows that when you want to make the server know the page change, you must submit, and submit it to change the status of the page. Of course, this also increases the complexity of keeping the page status. But don't matter, we will come slowly.
JSP and JavaScript integration
To say, what is the effect of JSP and JavaScript for users? Maybe someone started to throw eggs now. However, what do you think, how can I develop an ideal Application suitable for users? This is of course an angle of standing in the user. If you stand in the programmer's point of view, I will make many people ridicule, but for users, they don't care how much code you have, no matter what kind of database support you use, no matter how you use bubbles or quick sort They only care about the problem on the face. This article is not discussing artificial design. I have to achieve the same effects in JSP and JavaScript, but this is for users.
I also saw JSP variables on the 9CBS forum could not be called by JavaScript. JavaScript could not control JSP problems. The answer is usually two: The first kind is straightforward, "can't, this is two yards", Two kinds 不非 比 "" This is the server, one is the client, how it is possible, look at the book. " In fact, I don't know, this is a question that is very worth exploring.
But don't have a long, let's see the same effect as the user's angle, JSP and JavaScript.
Program 1: One direction control program, five buttons in the browser, up and down. Click on the button in the middle of the button to move up, click the button in the middle below to move down ... With this, click the middle button to restore the initial state.
Let's take a look at JSP code:
FIVEBUTTONS.JSP
<% @ Page ContentType = "text / html; charset = UTF-8" Language = "java"%> <% @ page import = "java.sql. *"%>
<%
Int Ileft;
INT ITOP;
IF (Request.GetParameter ("hidl")! = null) {
Ileft = integer.parseint (Request.GetParameter ("hidl"));
ITOP = INTEGER.PARSEINT (Request.GetParameter ("hidt"));
IF (Request.GetParameter ("btnu")! = Null && Request.getParameter ("btnu"). Compareto ("u") == 0)
ITOP - = 10;
IF (Request.getParameter ("BTND")! = NULL
&& Request.getParameter ("BTND"). Compareto ("D") == 0)
ITOP = 10;
IF (Request.GetParameter ("btnl")! = null
&& recomst.getParameter ("BTNL"). Compareto ("L") == 0)
Ileft - = 10;
IF (Request.GetParameter ("btnr")! = null
&& Request.getParameter ("btnr"). Compareto ("R") == 0)
Ileft = 10;
IF (Request.GetParameter ("btnm")! = null
&& Request.getParameter ("BTNM"). Compareto ("M") == 0) {
Ileft = 400;
ITOP = 200;
}
} else {
Ileft = 400;
ITOP = 200;
}
%>
HEAD>