开发者

How do I know what version of servlet-api.jar I have?

I downloaded a copy of servlet-api.jar fr开发者_运维知识库om java2s.com. How do I know what version it is? There's no reference on the site.

EDIT

Ah. Apologies. I should have listed the content of the wordpad output when I double clicked on the MANIFEST.MF file in the jar I got:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.5
Created-By: 1.5.0_06-b05 (Sun Microsystems Inc.)

As you can see it didnt tell me the version hence the question.


use the below code snippet :

<%= session.getServletContext().getMajorVersion() %>.
<%= session.getServletContext().getMinorVersion() %>


you can get it from META-INF, you can explore the content of jar file using win rar or such archiving utils something like.

Name: javax/servlet/
Specification-Title: Java API for Servlets
Specification-Version: 2.4  

I personally prefer maven repo to download jar from.


you can extract the MANIFEST.MF from the META-INF directory of your jar file by using

jar xf servlet-api.jar META-INF/MANIFEST.MF

the manifest for version 2.4 that comes with tomcat looks like this for example

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.2
Created-By: 1.4.2_06-b03 (Sun Microsystems Inc.)

Name: javax/servlet/
Specification-Title: Java API for Servlets
Specification-Version: 2.4
Specification-Vendor: Sun Microsystems, Inc.
Implementation-Title: javax.servlet
Implementation-Version: 2.4.public_draft
Implementation-Vendor: Apache Software Foundation


It's basically inside your JAR's MANIFEST file under /META-INF/MANIFEST.MF:

Name: javax/servlet/
Specification-Title: Java API for Servlets
Specification-Version: 3.0
Specification-Vendor: Sun Microsystems, Inc.
Implementation-Title: javax.servlet
Implementation-Version: 3.0.FR
Implementation-Vendor: Apache Software Foundation


for followers, if it's in a jnlp distro, there may be an accompanying "version.xml" file that tells you what versions each jar is respectively.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜