0

I have put a java project as a .jar (="Calculator_Project") into the WebContent/WEB-INF/lib folder.

This"Calculator_Project"need some temporary folders (debug,temp) and two folders with models and scripts in it (models,scripts).

I cannot change the way the "Calculator_Project" in the .jar need this folders. If i use the .jar in a normal java project and call the classes/methodes of the project with the needed folders it works fine.

When i put the code into a servlet the methodes of the "Calculator_Project" don't find the scripts and the folders. Where do i have to place this temporary and script-folders?

I already tried WEB-INF and WebContet folder of my dynamic web project. Do i need to declare this folders somewhere?

Edit: structure of the Dynamic Web Service:

enter image description here

Code of the Servlet where the classes and methodes of the normal project "Calcultor_Project" are executed:

/**
 * Servlet implementation class MasterServlet
 */
@WebServlet("/MasterServlet")
public class MasterServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#HttpServlet()
     */
    public MasterServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see Servlet#init(ServletConfig)
     */
    public void init(ServletConfig config) throws ServletException {


        Calculator calculator = new Calculator();
        final String modeldirectorypath = "model" ;
        final String modelname = "QualityCheck" ;

        // this methode need the extra-folders "debug","temp","models","scripts"
        CalculatorSlots [] slots = calculator.runEval(modeldirectorypath,modelname); 

    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //stuff to do
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
    }

}
Ghali
  • 275
  • 3
  • 15
  • We're not extra-lucid wizards. We can't see the code on your computer. – JB Nizet Apr 23 '15 at 19:07
  • What matters is the code of the calculator, which accesses the directories. That's where the path of the directories is defined. – JB Nizet Apr 23 '15 at 19:38
  • In the Calculators code it accesses debug by /debug , temp by /temp and scripts by /scripts/indicatorrunner and so on. - does that help? – Ghali Apr 23 '15 at 19:48
  • So, it looks for these directories at the root of the file system. – JB Nizet Apr 23 '15 at 20:36
  • and where would that be the root of the file system in a dynamic web project ? – Ghali Apr 23 '15 at 22:35
  • The root ot the file system is not inside your web project. It's at the root of the file system. i.e. the directory `/`on your machine. Don't you know what a file system is. Open a shell and type `cd /`(or `cd \\` on windows). That's the directory where you must create your directories. – JB Nizet Apr 24 '15 at 06:07
  • In the Calculators code it accesses debug by /debug , temp by /temp and scripts by /scripts/indicatorrunner of the current project foder it is running. So where is the root of a dynamic web project? – Ghali Apr 24 '15 at 07:34
  • I already answered to that, and still haven't posted the relevant code. Voting to close. – JB Nizet Apr 24 '15 at 07:36
  • Okay if you have answered that, i didnt recognise that - sorry for that. But I still dont know: where is the root directory of my dynamic web project. For example normal java projects its just its folder. – Ghali Apr 24 '15 at 07:49

1 Answers1

0

"The context root is the Web application root, which is the top-level directory of your application when it is deployed to the Web server. You can change the context root after you create a project using the project Properties dialog, which you access from the project's pop-up menu. The context root can also be used by the links builder to ensure that your links remain ready to publish as you move and rename files inside your project."

And this Quest helped: How to change context root of a dynamic web project in Eclipse?

Community
  • 1
  • 1
Ghali
  • 275
  • 3
  • 15