What is the difference between attribute and parameter in java




















First call the following setAttribute method in 1. The difference between getAttribute and getParameter. The parameter is the string; the attribute is the object 3. That is, the request. I found it after finding a lot of information. Yesterday, a friend asked me this question again, thinking that I was also confused at first, so I posted this question and let the same confused friend solve the puzzle.

Obviously, getParameter can only pass strings. SetAttribute is that the application server puts this object in the memory corresponding to the page. When your page server redirects to another page, the application server will copy this memory to the memory corresponding to the other page.

This way getAttribute can get the value you set, of course, this method can pass the object. The same is true for the session, only the life cycle of the object in memory is different. Personally think: request. In Action, request. The difference between request. The general web application, as chenshaizi Chen Shaobin said, is basically based on the transfer of Post mode, using getParameter to get the value.

For your own control, you can pass request. For the application of Structs framework, getAttribute is used a little more, basically use getParameter for others. My understanding: session. A student object can hav e attributes such as student id and name. An Employee can have attributes such as employee ID, name, salary and department.

An Animal object can have attributes such as name, favourite food etc. According to the above program, the Rhombus class has two attributes that are diagonal1 and diagonal2. It also has the constructor and a method to calculate the area.

In the main program, an object of Rhombus is created. Two values are passed to the constructor, and those will assign to the diagonal1 and diagonal2 attributes.

When calling the calArea method, the area of the Rhombus is calculated, and it will return the answer, which is a double value. Finally, the calculated area will print on the screen.

The two diagonal values are the attributes of the class and of the object r1. A Function is a major concept in programming. It is a set of statements to perform a specific task. Functions increase code reusability. There can be predefined functions provided by the programming language.

The programmer can also write his own functions. They are called as user-defined functions. The term parameter is associated with the function. A parameter is similar to a place holder. The syntax of the function is as follows. The access modifier represents the visibility of the method. It can be private, public etc. A JSP scriptlet is used to contain any code fragment that is valid for the scripting language used in a page.

Servlets and JSPs are considered outdated technologies and no longer chosen for the new projects. These were found in use significantly for legacy projects. Servlet JSPs were used enormously in around JavaServer Pages JSP is a Java standard technology that enables you to write dynamic, data-driven pages for your Java web applications.

Begin typing your search term above and press enter to search. Press ESC to cancel. Skip to content Home Blog What is the difference between request parameter and request attribute? Ben Davis March 28, What is the difference between request parameter and request attribute?

What is the difference between parameters and attributes? What is the return type of request getAttribute method? What is request getAttribute in JSP? Can we use request getParameter in JSP? What is the use of request in JSP? What is JSP life cycle? What JSP means?



0コメント

  • 1000 / 1000