Found 4336 Articles for Java 8

How to delete cookies with JSP?

Samual Sam
Updated on 30-Jul-2019 22:30:25

2K+ Views

To delete cookies is very simple. If you want to delete a cookie, then you simply need to follow these three steps −Read an already existing cookie and store it in Cookie object.Set cookie age as zero using the setMaxAge() method to delete an existing cookie.Add this cookie back into the response header.Following example will show you how to delete an existing cookie named "first_name" and when you run main.jsp JSP next time, it will return null value for first_name.Example Live Demo           Reading Cookies                       ... Read More

How to read cookies with JSP?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

1K+ Views

To read cookies, you need to create an array of javax.servlet.http.Cookie objects by calling the getCookies( ) method of HttpServletRequest. Then cycle through the array, and use getName() and getValue() methods to access each cookie and associated value.Let us now read cookies that were set in the previous example −Example Live Demo           Reading Cookies                        Reading Cookies                 Let us now put the above code in main.jsp file and try to access it. If you set ... Read More

How do you set cookies in the JSP?

Samual Sam
Updated on 30-Jul-2019 22:30:25

2K+ Views

Setting cookies with JSP involves three steps −Step 1: Creating a Cookie objectYou call the Cookie constructor with a cookie name and a cookie value, both of which are strings.Cookie cookie = new Cookie("key", "value");Keep in mind, neither the name nor the value should contain white space or any of the following characters −[ ] ( ) = , " / ? @ : ;Step 2: Setting the maximum ageYou use setMaxAge to specify how long (in seconds) the cookie should be valid. The following code will set up a cookie for 24 hours.cookie.setMaxAge(60*60*24);Step 3: Sending the Cookie into the ... Read More

How cookies work in JSP?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

181 Views

Cookies are usually set in an HTTP header (although JavaScript can also set a cookie directly on a browser). A JSP that sets a cookie might send headers that look something like this −HTTP/1.1 200 OK Date: Fri, 04 Feb 2000 21:03:38 GMT Server: Apache/1.3.9 (UNIX) PHP/4.0b3 Set-Cookie: name = xyz; expires = Friday, 04-Feb-07 22:03:38 GMT; path = /; domain = tutorialspoint.com Connection: close Content-Type: text/htmlAs you can see, the Set-Cookie header contains a name value pair, a GMT date, a path and a domain. The name and value will be URL encoded. The expires field is an instruction ... Read More

What are cookies in JSP?

Samual Sam
Updated on 30-Jul-2019 22:30:25

238 Views

Cookies are text files stored on the client computer and they are kept for various information tracking purposes. JSP transparently supports HTTP cookies using underlying servlet technology.There are three steps involved in identifying and returning users -Server script sends a set of cookies to the browser. For example, name, age, or identification number, etc.Browser stores this information on the local machine for future use.When the next time the browser sends any request to the web server then it sends those cookies information to the server and server uses that information to identify the user or may be for some other ... Read More

What are save points in JDBC? Explain?

Nancy Den
Updated on 30-Jul-2019 22:30:25

231 Views

Savepoint interface gives you the additional transactional control. Most modern DBMS, support save points within their environments such as Oracle's PL/SQL.When you set a save point you define a logical rollback point within a transaction. If an error occurs past a save point, you can use the rollback method to undo either all the changes or only the changes made after the save point.The Connection object has two new methods that help you manage save points −setSavepoint(String savepointName): Defines a new save point. It also returns a Savepoint object.releaseSavepoint(Savepoint savepointName): Deletes a Savepoint. Notice that it requires a Savepoint object ... Read More

What are the methods provided by the ResultSet to navigate through it in JDBC?

Nancy Den
Updated on 30-Jul-2019 22:30:25

248 Views

We have two types of ResultSet objects namely, forward Only and, bi-directional as the names suggest you can move in only one direction (forward) in forward only ResultSet and, in bidirectional ResultSet you can move the pointer in both directions. The ResultSet interface provides several methods to navigate through both types of ResultSet objects.Following table lists various methods to navigate through ResultSet object.MethodDescriptionnext()This method moves the resultset pointer one row forward.Previous() This method moves the resultset pointer one row backward.first()This method moves the resultset pointer to the first row.last()This method moves the resultset pointer to the last row.relative()This method accepts an ... Read More

What is JDBC SQL Escape Syntax Explain?

Nancy Den
Updated on 30-Jul-2019 22:30:25

1K+ Views

The escape syntax gives you the flexibility to use database specific features unavailable to you by using standard JDBC methods and properties.The general SQL escape syntax format is as follow:{keyword 'parameters'}Following are various escape syntaxes in JDBC:d, t, ts Keywords: They help identify date, time, and timestamp literals. As you know, no two DBMSs represent time and date the same way. This escape syntax tells the driver to render the date or time in the target database's format{d 'yyyy-mm-dd'}Where yyyy = year, mm = month; dd = date. Using this syntax {d '2009-09-03'} is March 9, 2009.Example//Create a Statement object ... Read More

How to update the contents of a ResultSet using a JDBC program?

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

90 Views

To update the contents of the ResultSet you need to create a statement by passing the ResultSet type updatable, as://Creating a Statement object Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);Just like getXXX() and setXXX() methods ResultSet interface also provides methods to update the contents of a row in a result set updateXXX().These methods accept integer values representing the index or, a String value representing the column label, of the row to be updated.Note that if you need to update the contents of a ResultSet the table should have a primary key.ExampleAssume we have a table named Employees with 5 records as shown ... Read More

What is a RowSet object explain using a JDBC program?

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

227 Views

A RowSet is a wrapper around a ResultSet Object. It can be connected, disconnected from the database and can be serialized. It maintains a JavaBean component by setting the properties. You can pass a RowSet object over the network. By default, RowSet object is scrollable and updatable and it is used to make a ResultSet object scrollable and updatable.You Can get a RowSet using theRowSetProvider.newFactory().createJdbcRowSet() method.ExampleAssume we have a table named dataset in the database as:+--------------+-----------+ | mobile_brand | unit_sale | +--------------+-----------+ | Iphone       |      3000 | | Samsung      |      4000 ... Read More

Advertisements