answersLogoWhite

0

Setting and getting session attributes is fairly easy. It is the same in both Servlets and JSPs with one exception. In a JSP, you already have access to the session object, and you do not have to declare it. In a Servlet, you must get the session like this: javax.servlet.http.HttpSession session = request.getSession(); Once you have done that, you can set a session object like this: session.setAttribute("name","value"); To retrieve the value, do this: String foo = (String) session.getAttribute("name"); A couple of things to keep in mind: * The second parameter in the setAttribute method is an Object, not a String. When you retrieve the value, you have to cast it. In the example above, I am casting it to a String. * If you try to perform a getAttribute on a session attribute that does not exist, or was not set, it will return a null. * Session attributes are not available using JavaScript. You can not set or get an attribute in JavaScript. * You do NOT need to do the 'session = request.getSession() in a JSP. It is only necessary in a Servlet.

User Avatar

Wiki User

15y ago

What else can I help you with?

Continue Learning about Information Science

What is sql-3?

SQL-3 is short for Structured Query Language Level 3, which is a standard that defines the syntax and semantics of SQL queries. It includes features like advanced outer joins, enhanced data manipulation capabilities, and support for recursive queries. SQL-3 builds upon SQL-92 and provides more advanced functionality for managing databases.


What is semi join in SQL?

A semi-join returns rows from one table that would join with another table without performing a complete join. It doesn't have explicit syntax. Eg : semi join to evaluate an exists sub query select * from Customers C where exists ( select * from Sales S where S.Cust_Id = C.Cust_Id ) Cust_Id Cust_Name ----------- ---------- 2 John Doe 3 Jane Doe


Where can one find more information regarding XSL online?

There are multiple online resources where you can find more information regarding XSL. Some popular options include the World Wide Web Consortium (W3C) website, which provides the official XSL specifications and documentation, as well as tutorial websites like W3Schools or Tutorials Point, which offer beginner-friendly explanations and examples of XSL concepts and syntax. Additionally, online forums and communities such as Stack Overflow can be valuable sources for specific questions and discussions related to XSL.


What are the advantages and disadvantages of SQL?

ADV 1. View the data without storing the data into the object. 2. Restrict the view of a table i.e. Can hide some of columns in the tables. 3. Join two or more tables and show it as one object to user. 4. Restrict the access of a table so that nobody can insert the rows into the table. DISADV 1. Can not use DML operations on this. 2. When table is dropped view becomes inactive.. It depends on the table objects. 3. It is an object so it occupies space


What is the use of query by example?

A query by example is where you fill in data that in effect acts like a sample of what you want the query to retrieve. So if you have a set of data of employees and want to show ones that work in a particular department, you would type the name of the department into the query to correspond to the field that shows the department. So in the query, you would have chosen your fields, and in the criteria under the department field you might type something like "Sales", indicating that you want records that have "Sales" in the department field. What you type in acts as an example of the data you want to get. You could use lots of criteria in different ways and build more complex queries, but still using a query by example approach.

Related Questions

What is the correct syntax for referring to an external script called testjs?

To refer to an external script called testjs.js, you would use the <script> tag in your HTML document. The correct syntax is: <script src="testjs.js"></script>. This tag should be placed within the <head> section or at the end of the <body> section of your HTML file to ensure proper loading of the script.


Syntax when using image tag to an HTML document?

The basic syntax is:Additional optional attributes include height, width, and border.


Where does the name syntax error come from?

syntax means synthesis that attributes comma,dash,slash and every keyword..however the deepest answer for evaluating this question is synthesis error.


Php Source code for validation?

If you wish to check the syntax of your source code, you need to run the code through the PHP CLI with the -l option. There are also some online resources to validate the syntax. This will check only the syntax of your file. This will not however detect runtime errors or logic errors. You must absolutely run the script for the best possible code validation.


What does HTML contain?

By contain I assume you mean the Syntax (Words), it is made up of tags such as and closing tags such as , also attributes such as to learn more about this visit http://w3schools.com/


Software for opening DXL ext files?

.dxl files are script files used for customising Telelogic DOORS. they can be edited through notepad or any other text editor. It is suggested though that using a syntax editor such as Crimson Edit or Xemacs with a DXL syntax file applied is better, then you can get syntax highlighting for key words, etc which makes debugging much simpler


What should I do when scope not digest in angular java script?

Apply $scope.$apply(); It's better to have apply in timeout syntax as below : SetTimeout(function() {$scope.$apply();},10);


Are HTML tags and syntax the same?

No. Syntax is/are the rules of the language, tags are part of the syntax.


How do you prevent syntax in programming?

Not possible; syntax cannot be avoided. (Syntax errors can be though.)


What are some common questions about syntax in programming languages?

Common questions about syntax in programming languages include: "What is syntax and why is it important?", "How does syntax differ between programming languages?", "What are some common syntax errors and how can they be avoided?", and "How can I improve my understanding of syntax in a programming language?"


Is database design language a programming language?

No, it doesn't comprise any binary or computer language syntax. It simply uses schematic to graphic representation of tables structures and attributes as a mechanism to ease to the design process.


How syntax affect setting?

Syntax is essential to any form of language. Without syntax, there is no setting, there is no way to explain it and no language. Language and setting are both comprised with syntax.