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:[EMAIL PROTECTED]
Sent: Wednesday, March 19, 2003 4:45 PM
To: [EMAIL PROTECTED]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to