Why some times tutorials make beans implement Serializable object and others do not? I know that object should be serialized when I want to send it through a network, so does that prove that each bean used in sessions should implements Serializable objects and beans defined in JSP pages should not since they are not transferred using HTTP requeset
Beans serialization in JSP
4.8k Views Asked by palAlaa At
2
There are 2 best solutions below
4
Charlie Martin
On
By definition, a well-formed Java Bean implements Serializable (which is just a tag interface anyway) or Externalizable (since 1.4) So if your bean class doesn't, it's not well-formed.
However, there's so much that does implement Serializable you can often get away with it if the bean has a well-known parent class.
Related Questions in JAVA
- Add image to JCheckBoxMenuItem
- How to access invisible Unordered List element with Selenium WebDriver using Java
- Inheritance in Java, apparent type vs actual type
- Java catch the ball Game
- Access objects variable & method by name
- GridBagLayout is displaying JTextField and JTextArea as short, vertical lines
- Perform a task each interval
- Compound classes stored in an array are not accessible in selenium java
- How to avoid concurrent access to a resource?
- Why does processing goes slower on implementing try catch block in java?
- Redirect inside java interceptor
- Push toolbar content below statusbar
- Animation in Java on top of JPanel
- JPA - How to query with a LIKE operator in combination with an AttributeConverter
- Java Assign a Value to an array cell
Related Questions in JSP
- Why we use double % in Java or JSP
- How to get specific values from select menu and use her in mysql query?
- How to compile an individual jsp file from command line
- How to keep a variable in the URL when using Spring LocaleChangeInterceptor
- How to pass value from input text to jsp variable?
- Importing a downloaded JAR file into a Servlet
- Upload PDF and display on same page
- Use javascript variables in JSP code
- How to add '%' symbol in textbox using jsf and jsp?
- Execute RequestDispatcher after 5 seconds
- Score book using javabean; how do I get overall average?
- Struts2 jqGrid DatePicker in Column Filter
- java.lang.StackOverflowError in spring controller
- Error on java application
- Requested Resource is not available error
Related Questions in JAVABEANS
- Score book using javabean; how do I get overall average?
- ArrayOutOfBoundsException on Bean creation while using Java 8 constructs
- How to iterate through all properties of a Java bean
- Login in Extjs using java spring Bean
- Looping Arraylist of Arrays java
- Instantiation of bean failed : Specified class is an interface
- The value for the useBean class attribute action.TestBean is invalid. How to correct it?
- Spring factory method
- Need to compare file Id for file uploading in java bean(old file and new file)
- using Primefaces poll to open dialog
- Debug while bean creation
- JSF panelGroup not getting rendered after ajax call
- Javabean Introspector - what is in my List?
- Create separate java bean for an ArrayList property
- Cannot create bean when start the application
Related Questions in HTTPSESSION
- Websphere 8.5.5 - shared session context not working
- Strange behavior : Spring Session Attributes vs ModelAttribute
- HttpSessionListener.sessionCreated() not being called
- get value from a session Object
- Session Management in Tomcat?
- resetting http session time out with httpSession.setMaxInactiveInterval(sec) is not working
- How does a tomcat server identify clients for creating session id
- What is the purpose of a JSESSIONID suffix?
- Setting non-serializable attribute value into HttpSession
- ASP.Net ReadOnly Session
- HttpContext.Current.Session equivalent in Spring MVC
- Strange behavior with Websockets, HTTPSessions and Chrome
- Where does the Grails Spring Security plugin save currentUser in HttpSession
- How to change JSESSIONID in Struts 2
- HttpSession Servlet don't work correctly from a servlet to a servlet
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
You seem to believe that objects in a session are sent to the client in the http transfer? That's certainly not the case. What is tranferred is only the session id (typically in a cookie). The servlet container (eg Tomcat) just keeps in memory the session objects (beans or not), indexed by the session id.
Besides, serialization does not only apply to network transfer, it also applies to save/load to persistent storage (eg disk).
Now, many servlet containers usually allow (depending on the settings) to persist the Session objects to disk so they can survive a app-server restart. For that scenario, to have your session objects serializable is a must.
Anyway, implementing the Serializable interface is a nice thing to have for every java bean, and usually it's easy.