As such there is no limit on the amount of information that can be saved in a Session Object. Only the RAM available on the server machine is the limitation. The only limit is the Session ID length(Identifier) , which should not exceed more than 4K. If the data to be store is very huge, then it’s preferred to save it to a temporary file onto hard disk, rather than saving it in session. Internally if the amount of data being saved in Session exceeds the predefined limit, most of the servers write it to a temporary cache on Hard disk.
There are couple of Methods. Firstly servers like JRun and others provide separate logs where all your Print requests will print their data into. For example requests to System.out. and System.err go to different log files. If this features is not available or you want to maintain logs separately for each module then you can create a static class called “LogWriter” and call the method inside the try catch loop. The print method in Log Writer will be writing to a custom defined Log File.
LogWriter.print(“Debug : The following error occurred at function …. ‘)
Also Inprise JBuilder supports Servlet Debugging. Please refer to JBuilder documentation for details.
Just as a Cautionary note, from your Servlets, never call System.exit(0). The results might be unpredictable. Might close down the entire Server. The Best way is to catch the Exception and either send resultant Error Page to the Browser or Write to a Log file and inform user about the Error.
Server Side push is useful when data needs to change regularly on the clients application or browser , without intervention from client. Standard examples might include apps like Stock’s Tracker, Current News etc. As such server cannot connect to client’s application automatically. The mechanism used is, when client first connects to Server, (Either through login etc..), then Server keeps the TCP/IP connection open.
It’s not always possible or feasible to keep the connection to Server open. So another method used is, to use the standard HTTP protocols ways of refreshing the page, which is normally supported by all browsers.
<META HTTP-EQUIV=”Refresh” CONTENT=”5;URL=/servlet/stockquotes/”>
This will refresh the page in the browser automatically and loads the new data every 5 seconds.
In this post, we will see the differences b/w stateless and stateful session beans.
Stateless Session Bean:
- Stateless session bean do not maintain state across method calls and transactions
The EJB server transparently reuses instances of the Bean to service different clients at the per-method level (access to the session bean is serialized and is 1 client per session bean per method.
- Used mainly to provide a pool of beans to handle frequent but brief requests. The EJB server transparently reuses instances of the bean to service different clients.
- Do not retain client information from one method invocation to the next. So many require the client to maintain on the client side which can mean more complex client code.
- Client passes needed information as parameters to the business methods. Performance can be improved due to fewer connections across the network.
Stateful Session Bean :
- A stateful session bean holds the client session’s state.
- It is an extension of the client that creates it.
- Its fields contain a conversational state on behalf of the session object’s client.
This state describes the conversation represented by a specific client/session object pair.
- lifetime of these are controlled by the client and cannot be shared between clients.
The key difference between an interface and the corresponding abstract class is that a class or interface can have unlimited number of immediate super interface but it can only have one super class.
There are two primary axes of “inheritance” an object-oriented language like java. Implementation inheritance is where the sub-class inherits the actual code implementation from the parent. Interface inhyeritance is where the sub-class adheres to the public interface of the parent.
Also java actally mixes the two notions together a bi…. java interfaces are nice and clean. When you implement an interface, you are stipulating that your class adheres to the “contract” of the interface that you spefified. Java class inheritance isn’t so clean when you sub-class in java you are getting both the code inheritance but you are also stipulating that you sub-class adheres to the contract of the interface of the parent class.
Abstrct class in java are just like regular java classes but with the added constraint that you cannot instance then directly. In terms of that added constraint, they are basically classes which don’t actually implement all lof the code specified by their “contract”.
- CallableStatement: This is used to retrieve the stored procedures from the database. ie., these statements are used when two or more SQL statements are retrieved over and over.
- PreparedStatement: These are pre-compiled statements which are stored in database. We are using these, if the same query is to be executed over and over.
- CreateStatement: This is used to execute single SQL statement.
It is possible to share the same object of stateless session bean by multiple clients.
A Server maintains a pool of objects in case of stateless session bean. And every When ever we send a request to the JSP file it checks the servlet representing the JSP file. Then the web container runs the jsp compiler that generates the servlet code
time for a request it uses one of the pool of objects which is free at that time. The server gets back that object in to the pool only after the client work on that object is Directory over [ client says that by invoking ejbremove() method]
After the client release that object, the server may used the same object to handle another client request, thus the same object to handle another client request. Thus the same object of stateless session can be shared by multiple clients But sharing the same object for multiple clients is not possible in case of state full session bean. Here server should maintain an object for every clients to handle / maintain the state of that object.
If a method is defined as final then we can’t provide the reimplementation for that final method in it’s derived classes i.e overriding is not possible for that method.
An abstract class contains one or mole abstract method. If all the methods ar of type abstract then use we can declare that class as abstract or interface. But in interface all the methods must be of type abstract.
We can declare final method in abstract class suppose of it is abstract too, then there is no used to declare like that.
Final abstract int test(String str);
Here we can’t provide the implementation for the test method as it is declared as final. But at the same time you declare it as abstract. [Abstract means it is responsibility of derived class to provide implementation for this] Here we can’t provide the implementation for the test method. Even we descried to provide implementation totally our meaning for declaring it as abstract is spoiled.
The isolation level measures concurrent transaction’s capacity to view data that have been updated, but not yet committed, by another transaction if other transactions were allowed to read data that are as yet uncommitted, those transactions could end up with inconsistent data were the transaction to roll back, or end up waiting unnecessarily were the transaction to commit successfully.
A higher isolation level means less concurrence and a greater likelihood of performance bottleneck, but also a decreased chance of reading inconsistent data. A good rule of thumb is to use the highest isolation level that yields an acceptable performance level. The following are common isolation levels, arranged from lowest to highest.
1) ReadUncommitted: Data that have been updated but not yet committed by a transaction my be read by other transactions
2) Readcommitted: Only data that have been committed by a transaction can be read by other transactions.
3) Repeatable Read: Only data that have been commited by a trasaction can be read by other transactions, and multiple reads will yield the same result as log as the data have been committed.
4) Serializable: This highest possible iosolation level, ensures a transaction’s execlusive read-write access to data, it includes the conditions of ReadCommitted and Repeatable Read and stiplulates that all transactions run serially to achieve maximum data integrity. This yields the slowest performance and least concurrency. The term serializable in this context is absolutely unrelated to the database.
A map cannot contain duplicate keys; each key can map to at most one value. The Map interface provides three collection views, which allow a map’s contents to be viewed as a set of keys, collection of values, or set of key-value mappings. The order of a map is defined as the order in which the iterators on the map’s collection views return their elements.The TreeMap class, make specific guarantees as to their order; others, like the HashMap class, do not.