Use JSP to develop the first Web application in my life

Source: Internet
Author: User

JBuilder leads my JSP journey

At that time, I left the annoying "management" position. In fact, I decided to start my own business, so I quit. Dramatic is that my first startup project was not a well-known PowerBuiler or Delphi, but it was just my weakness, Java Web programming.

The program was developed using Jbuilder and JSP technology. It was very simple, but it took me three months. In the past three months, I did not spend much time writing programs. Most of the time, I searched on Google. I have no time to systematically learn Java Web programming. I can only cross the river by feeling the stones. Fortunately, there are many "stones" on Google, and all the questions can be answered, although it may not be the best.

The development process is tense and happy. As a real programmer, I found my position and feeling. I am satisfied by pouring all my painstaking efforts on the keyboard and watching the code grow like bean sprout.

JSP makes me understand a lot of Web terms, Servlet, request, response, session, form, submission, Bean, etc. I am wandering in the JSP world, I feel that I have recovered my youth.

It is worth mentioning that Borland's Jbuilder is an excellent integrated development environment. Old programmers will be grateful to Borland. Since Turbo C, Borland has provided programmers with the best integrated development environment in the industry, whether it is C, Pascal, or Java, borland's development tools are trustworthy. Borland is recognized as an IDE master by programmers with simple configuration, user-friendly interface, powerful functions, excellent help documentation, detailed examples, and consistent and stable performance.

Like Turbo C, Jbuilder didn't disappoint me. Download, install, and run. Under the guidance of the help document, I wrote my first JSP page and clicked "Hello, world !" Haoran appeared in the browser window. At that moment, I stayed a little bit, not because it was all here, but because it was too fast. There is no configuration and no plug-ins need to be added. Borland has prepared everything for me.

Jbuilder is old. Is it still enough?

Unfortunately, Borland is old after all, and Jbuilder is obviously out of Eclipse. In the open-source era, the speed of product upgrades is not measured in years, but in months, weeks, or even days. The plug-in is obviously faster and easier than a new version. This is the cleverness of Eclipse. Eclipse is an empty skeleton, but countless programmers are adding flesh and blood to it, making Eclipse increasingly plump.

To be honest, Eclipse initially gave me a bad impression, and it took me N days to configure plug-ins. It is difficult for JSP to run in Eclipse. A poor plug-in can lead to abnormal death of Eclipse. In Jbuilder, you need the luck of winning the lottery. We miss Borland's Jbuilder very much. In fact, Jbuilder also has plug-ins called OpenTool. Unfortunately, it has never been popular. This should be a mistake in Borland's propaganda strategy, "Gold always shines" is good, but no advertisement, others can not see the light of gold.

The maximum Jbuilder version I have used is Jbuilder 2006. Compared with earlier Jbuilder versions such as 7 and 9, Jbuilder 2006 is too bloated. Jbuilder 7 can even run on PIII 600, which only has 2006 MB of memory, and Jbuilder. If there is no memory above 1 GB, you are ready to wait until all the flowers are done. Of course, compared with Sun's development environment, Jbuilder 2006 won't hit the memory killer anymore ).

From Jbuilder7 to Jbuilder 2006, if we judge it from the perspective of Java IDE alone, the surprise that Jbuilder brings to programmers is far less intense than the memory and hard disk space it occupies. What makes Jbuilder 2006 a giant? It is a product line plan launched by Borland. With the Unified Modeling Language, configuration management, and collaborative working environment, Borland has gone deep into almost all aspects of the software development lifecycle. Jbuilder is no longer a pure IDE.

Borland was born from the IDE. Should it be planted on the IDE? Amitabha.

Java Web compilation, C, and C ++

Using JSP technology to develop Web programs reminds me of assembler programs on Z80 and MCS51. The difference between a low-level language and a high-level language is reflected in whether the language is closer to the CPU or business. The assembly language is the closest language to the CPU and the farthest language from the business. Therefore, when programming in assembly language, only 1% of the time may be related to the business, in addition, 99% of the time is counted back and forth in the register. Advanced languages such as C ++ are very close to the business. Basically, you don't need to worry about memory, handle, and other things. Just concentrate on writing your business logic. C language is between Assembly and C ++. It is closer to the business than assembly, and closer to the CPU than C ++. On the one hand, the C language frees you from the entanglement of memory addresses and registers. On the other hand, if you want to, C can directly control the CPU. In fact, C can be embedded in assembly code. The reason why C is always prosperous and becomes a required language for computer science is inseparable from the powerful adaptability of C.

In the Java Web programming field, many technologies can be classified using similar methods. If Servlet is regarded as the "assembly language" of Web programming, the JSP technology built on Servlet is equivalent to the "C Language" of Web programming. JSF, which introduced the component model and event-driven model, is closer to the business end and can be regarded as the "C ++ language" of Web programming.

Servlet is the originator of Java Dynamic Web pages, providing the ability to generate dynamic content for Java Web pages. Servlet allows programmers to intervene in every byte the server returns to the browser, just as the Assembly Language allows programmers to access CPU registers. This gives programmers great power and brings a heavy burden. Programmers not only need to generate business-related information, but also add such informationAnd other HTML tags to display information in the user's browser in an appropriate way. In my opinion, this kind of "Nothing technical at all" should not waste valuable time on programmers.

JSP is a step forward than Servlet. At least, programmers do not have to worry about static HTML content. The Ugly HTML tags can now be handed over to tools for processing. The programmer's work is simplified to generate dynamic information based on the business logic, and then insert it to the appropriate location of the JSP file.

What about JSF? JSF, built on the basis of Servlet and JSP technology, not only has all the advantages of both, but also introduces the component model and event-driven model, this has brought about a huge revolution in Java Web programming, just as C ++ has brought about a shock in the C field. We will see this later.

Tedious Form processing in JSP

Obviously, displaying dynamic Web pages is far from all Web programming. In addition to displaying information, Web programs also need to collect information from users, which is the role of Form. JSP is very flexible in Form processing. It is precisely because of its flexibility that the Form processing of JSP is also very complicated. Flexibility is a double-edged sword in the world of programmers. For example, C is the most flexible programming language I have ever seen, but C is also the most complex programming language I have ever seen. Some C beginners are having to spend a few hours on teaching materials, and do not know what C's "reference" and "pointer" are.

Of course, JSP is not as complex as C, but it is enough to give programmers a headache. For example, a simple input interface is written in JSP. There is only one text input box and one button. You can enter the age in the text input box and press the button to submit it. In this process, the code to be written by the programmer includes:

◆ Obtain the JSP Request object;
◆ Since all input carried by the Request object is String, the programmer must convert String to the correct type. In this example, int is used;
◆ As users may enter illegal characters, such as abc, the programmer must handle the error of type conversion failure;
◆ The age cannot be-1 or 900. The programmer must perform a range check;
◆ User input is incorrect, so there is no need to say anything. The programmer must tell the user what is wrong;
◆ Even if the user inputs the error data, the programmer cannot simply clear it. The incorrect input must be displayed on the re-display input page so that the user can see what he just entered, therefore, the programmer needs to save the error input from the user and display it back;
◆ After the user finally enters the correct data, the programmer should save the result to the backend Bean or database;
◆ An error may occur when saving data. The programmer should notify the user, for example, to return an error page to the user;
◆ ......

It is just the simplest Form processing, and contains so many code snippets. The complexity of JSP is evident. In fact, code snippets are not special. They are the most common Java code. How to make these code snippets work together is the core of the problem. What about complex data tables with simple forms? My head is big.

Advantages of JSF claimed by Sun

As JSP is disappointing in Form processing, when my understanding of JSP is still in a vague stage, I have lost confidence in JSP, I think JSP is not worth the effort to learn. Now let's look back at the naive idea. Later, as I learned more about JSP, I gradually realized that JSP is actually a C language in the Java Web world, it is a sutra that any programmer who wants to practice in the Hall of Java Web must read.

Unfortunately, I didn't have such a foresight at that time, and I don't know how to ask the norm people around me. I downloaded J2EE Tutorial from Sun's website and hoped Sun would give me some advice. Sun has done this. In chapter 17th "assumerver Faces technology" of J2EE Tutorial, Sun said:

The well-designed programming mode and tag library can significantly reduce the establishment and maintenance of Web applications with server UI. You can easily:

◆ Associate client events with server application code;
◆ Bind the UI component on the page with the data on the server;
◆ Use reusable and scalable components to construct the user interface;
◆ Save and restore the UI status across requests;

The well-defined programming model and tag libraries significantly extends the burden of building and maintaining web applications with server-side UIs. With minimal effort, you can

◆ Wire client-generated events to server-side application code
◆ Bind UI components on a page to server-side data
◆ Construct a UI with reusable and extensible components
◆ Save and restore UI state beyond the life of server requests

After reading these lines of E-mails, I'm excited. Isn't that exactly what I need? In the component mode, event-driven, and data binding, all the weaknesses of JSP have been enhanced in JSF! I am very satisfied with JSF, and I am more satisfied that Jbuilder also supports JSF! So I decided immediately, and my next technical goal was JSF.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.