this is my java code in jsp file <% // loaded model getServletContext().getRealPath("/WEB-INF/en-token.bin"); InputStream modelIn = new FileInputStream("en-token.bin"); TokenizerModel model = new TokenizerModel(modelIn); if (modelIn != null) { try { modelIn.close(); } catch (IOException e) { } } // TokenizerME can be instantiated Tokenizer tokenizer = new TokenizerME(model); String tokens[] = tokenizer.tokenize("An input sample sentence."); for (int i=0;i<tokens.length;i++) { %>
I gives this error Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:404) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) > Date: Mon, 13 Jun 2011 12:07:23 -0400 > Subject: Re: Opennlp API > From: bimargul...@gmail.com > To: opennlp-users@incubator.apache.org > > One option is to put the bin file in WEB-INF, and then call > getServletContext().getRealPath("/WEB-INF/whatever.bin") in your jsp > file. > > > > > > On Mon, Jun 13, 2011 at 12:02 PM, Amal Elmah > <amalalthougha...@hotmail.com> wrote: > > > > thanks a lot for replying > > > > I have never used servlet I always use JSP when it comes to web > > development. So could you please tell me what do you mean by > > "you need to make the servlet API call to get a 'real' pathname for it", > > Give me a simple example or any link that could guide me? > > I also have another question you say > > " The .bin file is in the file system" > > where exactly should the file be? > > > > > > > >> Date: Sun, 12 Jun 2011 16:06:34 -0400 > >> Subject: Re: Opennlp API > >> From: bimargul...@gmail.com > >> To: opennlp-users@incubator.apache.org > >> > >> That's not how Java works. The .bin file is in the file system, and > >> you need to make the servlet API call to get a 'real' pathname for it. > >> There's no concept of 'current directory' of files next to jsp files > >> in a webapp. > >> > >> On Sun, Jun 12, 2011 at 4:03 PM, Amal Elmah > >> <amalalthougha...@hotmail.com> wrote: > >> > > >> > I managed to download models from the website using different browser > >> > when I tried to use models from my application I faced the problem that > >> > my program does not recognize bin files so it gives me the following > >> > error: > >> > java.io.FileNotFoundException: en-token.bin (??????? ??? ?????? ?????? > >> > ??? ????? ??????) > >> > java.io.FileInputStream.open(Native Method) > >> > java.io.FileInputStream.<init>(FileInputStream.java:120) > >> > java.io.FileInputStream.<init>(FileInputStream.java:79) > >> > org.apache.jsp.index_jsp._jspService(index_jsp.java:79) > >> > org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) > >> > javax.servlet.http.HttpServlet.service(HttpServlet.java:717) > >> > > >> > org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374) > >> > > >> > org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342) > >> > org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267) > >> > javax.servlet.http.HttpServlet.service(HttpServlet.java:717) > >> > > >> > The code I used is > >> > > >> > InputStream modelIn = new FileInputStream("en-token.bin"); > >> > TokenizerModel model = new TokenizerModel(modelIn); > >> > > >> > I put en-token.bin file with the ****.jsp files I donot know what is the > >> > problem? > >> > > >> > thanks guys, > >> > Amal > >> > > >> > > >> > > >