axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Freakazoid <freakazoi...@web.de>
Subject Re: Write temp- ile on tomcat
Date Sat, 03 Mar 2007 21:46:02 GMT
Thanks for the code. From the java view it seems to work, but when I try 
it in my web service it crashes, some NullPointerException is thrown. I 
think the exception is thrown when the ServletContext is created.

But I got my web service now to work in a different way, so that I don' 
t need a temporary file anymore.

Thanks for your help. I would have gotten that code you sent me on my own

Christoph

Jeff Greif schrieb:
> 1.  The various servlet docs are here
>
> http://java.sun.com/products/servlet/docs.html
>
> The API specs might be useful.  Which version depends on your version 
> of tomcat.
>
> 2.  Code sketch
>
> MessageContext msgCtx = MessageContext.getCurrentContext();
> |ServletContext srvCtx =
>    ((HttpServlet)msgCtx.getProperty(HTTPConstants.MC_HTTP_SERVLET))
>    .getServletContext();
> String realPath = srvCtx.getRealPath("temp/mytempfile");
>
> This latter is supposed to return a real path in the file system 
> (which will likely be inside the tomcat webapp running axis).  If you 
> put a temp directory where indicated, you could store a file there.
>
> Jeff
>
> |
>
> Freakazoid wrote:
>> Yes, the service is running within axis.
>>
>> I tried to implement what you said, but I didn't succeed, because I 
>> don't know anything about servlets. And I don't know the first step 
>> to do in my serviceStub, because all I get there is the 
>> requestDocument the client sent.
>>
>> If you know about it, and if I don't steal your time, it would be 
>> nice, if you could send me some code examples. Else it will not break 
>> my neck. Then I have to do a little, a bit ugly, workaround.
>>
>> Thanks though for your answer
>>
>> Christoph
>>
>>
>> Jeff Greif schrieb:
>>> If your service is implemented within axis, then it is running as part
>>> of the axis servlet.  You can get the servlet context via the
>>> MessageContext, and access paths within the webapp containing that
>>> servlet.  I think you get the HttpServletRequest from the
>>> MessageContext, get the ServletContext from that request.
>>>
>>> There is probably something tomcat-specific as well, but the above
>>> will work in any servlet container.
>>>
>>> Jeff
>>>
>>> On 3/2/07, Freakazoid <freakazoid81@web.de> wrote:
>>>> Hi.
>>>>
>>>> I have a little web service, which needs to write a temp file on a
>>>> tomcat server where the axis2-webapp is running. If I just use a name
>>>> for the file without any path, on a standard tomcat-server as unzipped
>>>> from the archive, the file appears in the bin file of the 
>>>> tomcat-server.
>>>> I could then get to the temp-directory by using "../temp/filename",
>>>> which works on a standard tomcat-server.
>>>>
>>>> But I have it installed under gentoo linux, where the bin-directory is
>>>> not in the same directory as the temp-directory, and so I cannot get
>>>> there with "../temp/filename".
>>>>
>>>> My Question is, if there is some kind of environment-variable or
>>>> something like that, which I can use to get to the temp-directory and
>>>> would the code look like? I have seen something like that in a servlet
>>>> but could not use it in my service, because it is not a servlet :)
>>>>
>>>> I hope it is not to much a tomcat question for this mailing-list.
>>>>
>>>> Greets
>>>> Christoph Heyen
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>>>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Mime
View raw message