on 11-23-2007 3:21 PM
Hi,
Sorry if my question looks stupid. I'm relativly new to the J2EE environment. (i have lot of more experience with Microsoft world).
I have created 1 servlet , and 1 Java application (that should be deployed via webstart).
Then i have created an Entreprise Application project (MyApplication_EAR) that refers to the servlet (MyServlet_WEB) and the Java application project (that generates MyTestApp.jar)
When i deploy the EAR on the server , i see that the servlet war file is deployed in :
..\j2ee\cluster\apps\sap.com\MyApplication_EAR\servlet_jsp\MyServlet_WEB
I see also that the Java application 's jar is deployed in :
...\j2ee\cluster\apps\sap.com\MyApplication_EAR\app_libraries_container
I need in my Servlet to have an URL pointing on the MyTestApp.jar which is int he app_libraries_container.
How can i find this URL?
thanks in advance for your help.
Jean-Philippe.
Hi,
I assume that you need some resource from MyTestApp.jar in your servlet. You can obtain that with
getClass().getResource(resourcePath)
in your servlet class.
HTH!
-- Vladimir
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vladimir,
Thanks for your answer.
But not , it is not for that purpose. I don't need resource from MyTestApp.jar in my servlet. I just need to have the URL that points to that file.
MyServlet generates in memory a XML file where some attributes refers to MyTestApp.jar as URL and then the XML file is sent to the client using the HttpServletResponse .
I managed to put MyTestApp.jar in the :
(seeing from Project Explorer view) MyServlet_WEB\Webcontent\WEB-INF\lib
When the jar is here, it is deployed on the server under :
..\j2ee\cluster\apps\sap.com\.MyApplication_EAR\servlet_jsp\MyServlet_WEB\root\WEB-INF\lib
Now , how can i get the URL to the jar file?
I know how to get the ServletPath and URL of my servlet. But i don't manage to find the URL of a file which is in WEB-INF\Lib .
i would expect it is : Http://MyServer:MyPort/MyServlet_WEB/root/WEB-INF/lib/MyTestApp.jar
or
Http://MyServer:MyPort/MyServlet_WEB/WEB-INF/lib/MyTestApp.jar
But it seems not.
It doesn't help me.
May be i asked the question in a wrong shape. Let me reformulate.
How can i deploy a .JAR file on the SAP WebAS in the manner that the .JAR file can be accessed directly from the client browser that way :
Http://<Server>:<Port>/Folder/Myfile.Jar
Thanks
OK, let me summarize what I understood about your use case. In your servlet you need to generate a URL to this JAR file on the server, which you want to send back to the client so that they can access it through a browser.
I already explained how to make the JAR file available on the server, in a subdirectory of the web app (you can also put the JAR on the root level in the WAR so that it appears exactly under http://<Server>:<Port>/Folder/Myfile.Jar). With the beforementioned methods in the ServletContext API you can build this URL and send it back to the client.
Hope this makes things clearer now.
-- Vladimir
Thanks.
That's what i did ( put the JAR on the root level in the WAR and use the ServletContext API to build the URL) and it works.
But here i have to builf first my Jar, then copy it in the WAR then deploy the WAR.
In a "Non SAP World" , i would do that using Ant Script. But here i'm using the DTR and CBS . And i don't really see how to automise that.
I thought there was a project type, that simply build the jar and deploy it where i want , without having to copy it in the Webapplication Project.
But may be it is another question i should ask in another location in the forums.
Anyway thanks a lot for your help and your patience.
Well, all resources that a web app provides via HTTP to its clients have to be packed in the web app archive (WAR). You "copy" the JAR into the WAR with the different options available in the context menu of the web module project. This is a standard WTP feature for Java EE development and deployment, not SAP-specific.
HTH!
-- Vladimir
PS. If your question is answered please close the thread accordingly.
"You "copy" the JAR into the WAR with the different options available in the context menu of the web module project"
that's the problem, i need that this copy process be done <b>automatically</b> on the build server "CBS" which is coupled with the DTR.
But i guess that another question and close this topic , all that you said confirm me what i have found by myself , It has been helpful and clarified some doubt i had, thank a lot.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.