내 커뮤니티 업적 표시줄을 확대합니다.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

Usage of serialVersionUID in custom servlets which extends SlingSafeMethodsServlet

Avatar

Level 8

Hi All,

I have seen in multiple instances wherein serialVersionUID is assigned some random Long value in custom servlet. I am not sure as to why exactly is this used. Don't see this variable getting used anywhere.

Can someone please let me know as to what purpose does it serve.

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Level 4

Hi,

serialVersionUID is a Java "thing" for Serializable classes: Stream Unique Identifiers.
It's used by the regular Java serialization mechanism: Serializable Objects.

Regarding the "random" long value it has probably been generated/assigned by an IDE (Eclipse, IntelliJ), based on the characteristics of the corresponding class.

Some additional references about Servlets and serialization:

  1. Why does HttpServlet implement Serializable?
  2. Why do GenericServlet and HttpServlet implement the Serializable interface?

Best regards,

Daniel.

원본 게시물의 솔루션 보기

5 답변 개

Avatar

Level 4

Hi.

serialVersionUID is a Java "thing" for Serializable classes: Stream Unique Identifiers.
It's used by the regular Java serialization mechanism: Serializable Objects.

Regarding the "random" long value, it has probably been generated/assigned by an IDE (Eclipse, IntelliJ), based on the characteristics of the corresponding class.

Some additional references about Servlets and serialization:

Best regards,

Daniel.

Avatar

Level 10

Avatar

정확한 답변 작성자:
Level 4

Hi,

serialVersionUID is a Java "thing" for Serializable classes: Stream Unique Identifiers.
It's used by the regular Java serialization mechanism: Serializable Objects.

Regarding the "random" long value it has probably been generated/assigned by an IDE (Eclipse, IntelliJ), based on the characteristics of the corresponding class.

Some additional references about Servlets and serialization:

  1. Why does HttpServlet implement Serializable?
  2. Why do GenericServlet and HttpServlet implement the Serializable interface?

Best regards,

Daniel.

Avatar

Level 10

Avatar

Level 8

Thanks a lot Scott and Daniel for your replies.