Re: can not read or write to a file on the server side
ih... i have a problem again in writing in a file.. i'm sorry but i'm a newbie in GWT [...] import java.io.FileWriter; [...] private void postFile(String fileXml) { try { ServletContext sc = this.getServletConfig().getServletContext(); BufferedWriter out = new BufferedWriter(new FileWriter(sc.getRealPath(/blabla.xml))); } catch (Exception e) { e.getStackTrace(); } } i have the following error: in FileWriter: java.io.FileWriter is not supported by GAE's JRE.Why? i need to complete this method for writing in the file a String fileXml.. how can i do? -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: can not read or write to a file on the server side
yeeeah it works! thaks thaks thaks thaks thaks thaks thaks :D On Apr 8, 1:41 pm, HDayi hacid...@gmail.com wrote: hi andrew, when you give only the file name, tomcat does not use your application directory to access it. it uses it's own installation directory. so you must use the exact path of the file or use ServletContext as i mentioned abow. shortly you must do fallowing: for reading the file: ServletContext sc = this.getServletConfig().getServletContext(); InputStream is = sc.getResourceAsStream(/blabla.txt); BufferedReader input = new BufferedReader(new InputStreamReader(is)); then you can acces your file correctly. while wrting the file: ServletContext sc = this.getServletConfig().getServletContext(); BufferedWriter out = new BufferedWriter(new FileWriter(sc.getRealPath(/blabla.txt))); if you are using linux, tomcat user must have read and write rights of the file. good luck -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: can not read or write to a file on the server side
ok, now i have to do the same in the client-side.. there is no method getServletConfig() how can i do? -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: can not read or write to a file on the server side
mmm.. it's strange.. neither if i make an HTTP GET request with a RequestBuilder like this? RequestBuilder xmlFile = new RequestBuilder(RequestBuilder.GET, / blabla.xml); try { xmlFile.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable exception) { requestFailed(exception); } public void onResponseReceived(Request request, Response response) { parseXML(response.getText()); } }); } catch (RequestException ex) { requestFailed(ex); } On Apr 8, 10:42 pm, Katharina Probst kpro...@google.com wrote: Well, your app won't just be able to access the file system on the client side, because the browser runs in a sandbox (you wouldn't want any web app reading your files from your desktop...). But you *could* have the user upload a file, if that's what you want? Seehttp://google-web-toolkit.googlecode.com/svn/javadoc/2.0/com/google/g... . kathrin -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: can not read or write to a file on the server side
now have done in this way.. try { String fileXml = new String(); String s = new String(); FileReader f = new FileReader(vini.xml); BufferedReader br = new BufferedReader(f); do { s = br.readLine(); if (s!=null) fileXml=s; } while (s!=null); it works while debugging.. but when i deploy: java.io.FileNotFoundException: vini.xml (No such file or directory)java.io.FileNotFoundException: vini.xml (No such file or directory)[Ljava.lang.StackTraceElement;@115126e the file is present in this dir /var/lib/tomcat6/webapps/rpcTest0.. and i can't get the absolute path of f because there is no method.. grr -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: can not read or write to a file on the server side
the file is perfectly localized in the correct directory, i know because the debug in eclipse works...!! it's here /var/lib/tomcat6/ webapps/rpcTest0 where rpcTest0 is the project.. boh i'm from italy.. near modena, im a student of computer science at unibo, it's about 3 weeks that i try to learn gwt cause i will have a project for the university that need it.. this is just an exercise to make practice in preparation of... the whole exercise is to read an xml file and write it in the browser.. but if i can't read it i can't go ahead.. uff and what about you? are u italian too? whats your occupation? On Apr 7, 2:36 pm, Giovanni Gaglione giovanni.gagli...@gmail.com wrote: It seems that application doesn't find the file. Where is your file? It's possible that you must specify the file path better. Where are you from? What are you doing with GWT? Who are you? regards 2010/4/7 andrew19881123 andrew19881...@gmail.com now have done in this way.. try { String fileXml = new String(); String s = new String(); FileReader f = new FileReader(vini.xml); BufferedReader br = new BufferedReader(f); do { s = br.readLine(); if (s!=null) fileXml=s; } while (s!=null); it works while debugging.. but when i deploy: java.io.FileNotFoundException: vini.xml (No such file or directory)java.io.FileNotFoundException: vini.xml (No such file or directory)[Ljava.lang.StackTraceElement;@115126e the file is present in this dir /var/lib/tomcat6/webapps/rpcTest0.. and i can't get the absolute path of f because there is no method.. grr -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.comgoogle-web-toolkit%2Bunsubs cr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: can not read or write to a file on the server side
il mio e' un progetto x tecnologie web.. anche io sn alla triennale.. i permessi di linux li ho settati senza problemi.. ho provato agirare un po su google x cercare come sbloccare i file su tomcat.. e ho letto che c'e' da aggiungere grant{...} dentro alle policy solo che nn ho concluso nnt.. avevo provato anche io a creare un file.. cosi' da vedere dv cavolo lo mette e d conseguenza c piazzo il mio xml.. l'avevo fatto cosi': File file = new File(test.txt); if (file.exists()) { file.delete(); } try { file.createNewFile(); } catch (IOException e1) { e1.printStackTrace(); } System.out.println(Before. canWrite? + file.canWrite()); // set to read-only, atau canWrite = false file.setWritable(false); System.out.println(After. canWrite? + file.canWrite()); il problema e' che sempre x colpa dei permessi java nn puo scrivere nella cartella.. oltretutto ho provato anche un altro metodo x leggere un file, solo che in seguito al metodo canWrite() scatta l'eccezione e nn capisco il motivo dato che dovrebbe essere solo un si o un no.. vedi se riesci a creare il file con quel codice e poi fammi sapere ciao On Apr 7, 3:52 pm, Giovanni Gaglione giovanni.gagli...@gmail.com wrote: auhauha Io pure sono italiano di roma però. sto facendo la tesi per la laurea triennale in informatica...e utilizzo gwt da un mesetto o di più. Hai settato i permessi per il filesystem come ti avevo suggerito? Se il file non ha il permesso di essere letto, tomcat non lo trova. Che io sappia, ci stanno anche i permessi di tomcat sui file, magari potrebbe dipendere da questo. Se sgoogli un pochino, potresti vedere se è il caso tuo, vedendo come si settano i permessi di tomcat. Usi firebug? ti può convenire usarlo per vedere nel codice se è tutto aposto, se c'è qualche errore javascript, non so se mi spiego. Ma cosa ci stai facendo con gwt? Sai per caso come creare un file lato server? ti è capitato di fare un operazione simile con gwt? saluti 2010/4/7 andrew19881123 andrew19881...@gmail.com the file is perfectly localized in the correct directory, i know because the debug in eclipse works...!! it's here /var/lib/tomcat6/ webapps/rpcTest0 where rpcTest0 is the project.. boh i'm from italy.. near modena, im a student of computer science at unibo, it's about 3 weeks that i try to learn gwt cause i will have a project for the university that need it.. this is just an exercise to make practice in preparation of... the whole exercise is to read an xml file and write it in the browser.. but if i can't read it i can't go ahead.. uff and what about you? are u italian too? whats your occupation? On Apr 7, 2:36 pm, Giovanni Gaglione giovanni.gagli...@gmail.com wrote: It seems that application doesn't find the file. Where is your file? It's possible that you must specify the file path better. Where are you from? What are you doing with GWT? Who are you? regards 2010/4/7 andrew19881123 andrew19881...@gmail.com now have done in this way.. try { String fileXml = new String(); String s = new String(); FileReader f = new FileReader(vini.xml); BufferedReader br = new BufferedReader(f); do { s = br.readLine(); if (s!=null) fileXml=s; } while (s!=null); it works while debugging.. but when i deploy: java.io.FileNotFoundException: vini.xml (No such file or directory)java.io.FileNotFoundException: vini.xml (No such file or directory)[Ljava.lang.StackTraceElement;@115126e the file is present in this dir /var/lib/tomcat6/webapps/rpcTest0.. and i can't get the absolute path of f because there is no method.. grr -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.comgoogle-web-toolkit%2Bunsubs cr...@googlegroups.comgoogle-web-toolkit%2Bunsubs cr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.comgoogle-web-toolkit%2Bunsubs cr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en. -- You received this message because you
Re: can not read or write to a file on the server side
ma guarda.. gwt o no cmq sto programmando in java su lato server con le api d java x cui e' come se nn lo usassi proprio... sto odiando tomcat... On Apr 7, 4:07 pm, bitliner giovanni.gagli...@gmail.com wrote: Non posso provare ora il codice, nè penso stasera. Troppo impegnato. E' probabile che devi configurare meglio tomcat, ma non hai trovato nulla di qualcuno che affrontasse il tuo stesso problema? Indipendentemente da gwt? non so come altro aiutarti saluti On Apr 7, 4:03 pm, andrew19881123 andrew19881...@gmail.com wrote: il mio e' un progetto x tecnologie web.. anche io sn alla triennale.. i permessi di linux li ho settati senza problemi.. ho provato agirare un po su google x cercare come sbloccare i file su tomcat.. e ho letto che c'e' da aggiungere grant{...} dentro alle policy solo che nn ho concluso nnt.. avevo provato anche io a creare un file.. cosi' da vedere dv cavolo lo mette e d conseguenza c piazzo il mio xml.. l'avevo fatto cosi': File file = new File(test.txt); if (file.exists()) { file.delete(); } try { file.createNewFile(); } catch (IOException e1) { e1.printStackTrace(); } System.out.println(Before. canWrite? + file.canWrite()); // set to read-only, atau canWrite = false file.setWritable(false); System.out.println(After. canWrite? + file.canWrite()); il problema e' che sempre x colpa dei permessi java nn puo scrivere nella cartella.. oltretutto ho provato anche un altro metodo x leggere un file, solo che in seguito al metodo canWrite() scatta l'eccezione e nn capisco il motivo dato che dovrebbe essere solo un si o un no.. vedi se riesci a creare il file con quel codice e poi fammi sapere ciao On Apr 7, 3:52 pm, Giovanni Gaglione giovanni.gagli...@gmail.com wrote: auhauha Io pure sono italiano di roma però. sto facendo la tesi per la laurea triennale in informatica...e utilizzo gwt da un mesetto o di più. Hai settato i permessi per il filesystem come ti avevo suggerito? Se il file non ha il permesso di essere letto, tomcat non lo trova. Che io sappia, ci stanno anche i permessi di tomcat sui file, magari potrebbe dipendere da questo. Se sgoogli un pochino, potresti vedere se è il caso tuo, vedendo come si settano i permessi di tomcat. Usi firebug? ti può convenire usarlo per vedere nel codice se è tutto aposto, se c'è qualche errore javascript, non so se mi spiego. Ma cosa ci stai facendo con gwt? Sai per caso come creare un file lato server? ti è capitato di fare un operazione simile con gwt? saluti 2010/4/7 andrew19881123 andrew19881...@gmail.com the file is perfectly localized in the correct directory, i know because the debug in eclipse works...!! it's here /var/lib/tomcat6/ webapps/rpcTest0 where rpcTest0 is the project.. boh i'm from italy.. near modena, im a student of computer science at unibo, it's about 3 weeks that i try to learn gwt cause i will have a project for the university that need it.. this is just an exercise to make practice in preparation of... the whole exercise is to read an xml file and write it in the browser.. but if i can't read it i can't go ahead.. uff and what about you? are u italian too? whats your occupation? On Apr 7, 2:36 pm, Giovanni Gaglione giovanni.gagli...@gmail.com wrote: It seems that application doesn't find the file. Where is your file? It's possible that you must specify the file path better. Where are you from? What are you doing with GWT? Who are you? regards 2010/4/7 andrew19881123 andrew19881...@gmail.com now have done in this way.. try { String fileXml = new String(); String s = new String(); FileReader f = new FileReader(vini.xml); BufferedReader br = new BufferedReader(f); do { s = br.readLine(); if (s!=null) fileXml=s; } while (s!=null); it works while debugging.. but when i deploy: java.io.FileNotFoundException: vini.xml (No such file or directory)java.io.FileNotFoundException: vini.xml (No such file or directory)[Ljava.lang.StackTraceElement;@115126e the file is present in this dir /var/lib/tomcat6/webapps/rpcTest0.. and i can't get the absolute path of f because there is no method.. grr -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email
Re: can not read or write to a file on the server side
i have a similar problem with an xml file that i try to read.. the code for read is: try { File fileXml = new File(./vini.xml); System.out.println(hi); System.out.println(owner's write permission : +fileXml.setWritable(true)); //exception cached System.out.println(owner's read permission : +fileXml.setReadable(true)); ... } catch (Exception e) { lst += e; //browser output e.getStackTrace(); //console output } while debugging the output in the browser is: java.security.AccessControlException: access denied (java.io.FilePermission ./vini.xml write) if i don't set the fileXml.setWritable(true) it works fine! but not when i deploy the app in tomcat6 where can i set the permissions? i tried to add this grant codeBase file:${catalina.home}/bin/tomcat-juli.jar { permission java.security.AllPermission; }; in /etc/tomcat6/policy.d/03catalina.policy but it doesn't work On Apr 6, 3:44 pm, HDayi hacid...@gmail.com wrote: i am trying to open the file with the fallowing code: BufferedReader input = new BufferedReader(new FileReader(blabla.txt)); it works while developping with eclipse. and i am trying to write whit the fallowing: BufferedWriter out = new BufferedWriter(new FileWriter(blabla.txt)); out.write(liste); out.close(); both works fine on eclipse. when i upload to server the first one gives a long error message saying file not found in tomcat log file as i mentioned before. second one gives onli on word in tomcat log Exception. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: can not read or write to a file on the server side
I tried in a lot of way to read an external file, but i continue to have the same problem with permission.. i can read the file with jetty but not with tomcat.. can someone post me a guide or a stupid tutorial?? thx -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
include an external file when deploy
I have a problem with an external file when i deploy my application: in the source code at the server side i have inserted a File (File fileXml = new File(wine.xml); ), when i debug it works good, i can see all the elements, but after i make the GWT Compile, put all files in a war archive and then uploaded it in tomcat i can't see the elements, like as the path of the XML is wrong.. i can't figure out why.. the file wine.xml is in this folder MyApp/war thanks, Andrew -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.