struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Laurent de Menditte" <ldeme...@webtiss.com>
Subject Re: Problem while opening file in Action servlet
Date Wed, 19 Mar 2003 13:12:46 GMT
OK, the file could be found.
Now, do you have an idea of how I can do in order to make my API class read
this file without error?

Laurent

----- Original Message -----
From: "Mohan Radhakrishnan" <MohanR@hclcomnet.co.in>
To: "'Struts Users Mailing List'" <struts-user@jakarta.apache.org>
Sent: Wednesday, March 19, 2003 12:23 PM
Subject: RE: Problem while opening file in Action servlet


> Hi,
>
>    If your problem is that you need to check if that file is there or not
,
> then this might help
>
> if( getServlet().
> getServletContext().getResourceAsStream(
> resource ) == null ){
> logger_.debug("Not found" );
> } else {
> logger_.debug("Found" );
> }
>
> Mohan
>
> -----Original Message-----
> From: Laurent de Menditte [mailto:ldemendi@webtiss.com]
> Sent: Wednesday, March 19, 2003 4:45 PM
> To: struts-user@jakarta.apache.org
> Subject: Problem while opening file in Action servlet
>
>
> Hi,
>
> I'm using Struts 1.1 rc1, Tomcat 4.1.18
> I've written this Action class:
> --------------------------------
> import java.io.*;
> import javax.servlet.ServletException;
> import javax.servlet.http.HttpServletRequest;
> import javax.servlet.http.HttpServletResponse;
> import org.apache.struts.action.Action;
> import org.apache.struts.action.ActionForm;
> import org.apache.struts.action.ActionForward;
> import org.apache.struts.action.ActionMapping;
> import mypackage.API;
>
> public class MyAction extends Action {
>
>  public ActionForward execute(ActionMapping mapping,
>    ActionForm form,
>    HttpServletRequest request,
>    HttpServletResponse response)
>    throws IOException, ServletException {
>
>     String cible = new String("success");
>     try {
>         String ConfigurationFile = "test.ini";
>         FileInputStream Fin = new FileInputStream(ConfigurationFile);
>         API api = new API();
>     } catch (Exception e)
>     {
>         e.printStackTrace();
>     }
>     ...
>     return (mapping.findForward(cible));
>     }
> }
> ---------------------------------
> and my problem is that I catch a FileNotFoundException because the
test.ini
> file can't be found.
> I've got the same problem while creating the API object: a configuration
> file is also needed during that creation and can't be found.
> How can I solve this problem?
> I just want to add that I can't modify the API class, so that I can't
> specify the full path of the configuration file.
>
> Thanks for your answers.
> Laurent
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


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


Mime
View raw message