You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Aggarwal, Rajat" <ra...@razorsight.com> on 2008/07/02 09:37:26 UTC

How to get Web Application path at Run-Time

Hi All,

 

I am developing a web application using the struts 2 framework. In one
of the actions, I need to create a file at the run-time at a particular
location relative to the path where my web-application is deployed. How
can I retrieve the path at which my Web-app is deployed at run-time in
my action class?

 

An early response shall be appreciated

 

Thanks and regards

 

Rajat Aggarwal

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


Struts2 file upload and div contol in same form

Posted by Saqib Shehzad <sa...@tcm.com.pk>.
Hi,

I am trying to use ajax div and file control in same form. But div is not
loading properly instead it shows [object HTMLDocument] on firefox and
[object] on IE. But if I try to use them separately then both are working
fine. Anyone has has any idea what is happening ??? Here is the code
/***************************************************************************
**********************************


<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
 <%@ taglib prefix="s" uri="/struts-tags" %>
 <html>
 <head>
 <s:head theme="ajax" />
 <link href="<s:url value="/css/campaign.css"/>" rel="stylesheet"
   type="text/css"/> 
     <title>upload and ajax test</title>
 </head>
 <script>
  function changeApplication()
  {
        dojo.event.topic.publish("change_Application");
  }
  </script>
 <body>
 <s:url id="updateSecondList" action="updateSecondList" />
   
    <s:actionerror />
    <s:fielderror />
     <s:form id="test_form" name="test_form" action="FileAction"
method="POST" theme="ajax" enctype="multipart/form-data">
     
         <s:select
             label="First List"
            list="firstList"
            name="selectedItem"
            onchange="javascript:changeApplication();return false;">
        </s:select>
       
        <tr>
        <td class="tdLabel"><label class="label">Second List</label></td>
        <td>
        <s:div showLoadingText="false"
             id="details" href="%{updateSecondList}" theme="ajax"
             listenTopics="change_Application" formId="test_form">
         </s:div>                           
        </td>
        </tr>
       
        <s:file name="upload" label="File"/>
        <s:submit />
     </s:form>
 </body>
 </html>
/***************************************************************************
******************************/
Regards


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


Re: How to get Web Application path at Run-Time

Posted by Lukasz Lenart <lu...@googlemail.com>.
> I am developing a web application using the struts 2 framework. In one
> of the actions, I need to create a file at the run-time at a particular
> location relative to the path where my web-application is deployed. How
> can I retrieve the path at which my Web-app is deployed at run-time in
> my action class?

You can implement in action ServletContextAware interface [1], you
will get access to ServletContext then you have getRealPath(String)

[1] http://struts.apache.org/2.1.2/struts2-core/apidocs/org/apache/struts2/util/ServletContextAware.html


Regards
-- 
Lukasz
http://www.lenart.org.pl/

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


Re: How to get Web Application path at Run-Time

Posted by Paweł Wielgus <po...@gmail.com>.
Hi,
for example:
filterConfig.getServletContext().getRealPath("")
in FilterDispatcher.init(...) method.

Best greetings,
Paweł Wilegus.

On 02/07/2008, Aggarwal, Rajat <ra...@razorsight.com> wrote:
> Hi All,
>
>
>
>  I am developing a web application using the struts 2 framework. In one
>  of the actions, I need to create a file at the run-time at a particular
>  location relative to the path where my web-application is deployed. How
>  can I retrieve the path at which my Web-app is deployed at run-time in
>  my action class?
>
>
>
>  An early response shall be appreciated
>
>
>
>  Thanks and regards
>
>
>
>  Rajat Aggarwal
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>  For additional commands, e-mail: user-help@struts.apache.org
>
>