What have you written to date that works?
package praca.app;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Properties;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
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;
public final class LogoffAction extends Action
{
/** funkcja ta wykonuje akcje zamkniecia sesji
* @param mapping akcja
* @param form przypisany do klasy ActionForm
* @param request zapytanie
* @param response odpowiedz
*/
public ActionForward perform(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
//pobranie obiektu z sesji
HttpSession session = request.getSession();
LogonForm user = (LogonForm)
session.getAttribute(Constants.USER_KEY);
//logowanie akcji do servera aplikacji
if (user != null) {
if (servlet.getDebug() >= Constants.DEBUG) {
StringBuffer message =
new StringBuffer("LogoffAction: Uzytkownik '");
message.append(user.getUsername());
message.append("' wylogowal sie z sesji numer: ");
message.append(session.getId()+" adres IP klienta:
"+request.getRemoteAddr());
servlet.log(message.toString());
}
}
else {
if (servlet.getDebug() >= Constants.DEBUG) {
StringBuffer message =
new StringBuffer("LogoffAction: Uzytkownik '");
message.append(session.getId());
servlet.log(message.toString());
}
}
//zapisanie danych z obiektow sesji do plikow typu properties
Properties properties = new Properties();
Properties properties2 = new Properties();
Hashtable ht =
((PrawaAll)session.getAttribute("PrawaAll")).getPrawa();
Hashtable ht2 = ((Users)session.getAttribute("Users")).getUsers();
Enumeration emu = ht.keys();
while(emu.hasMoreElements())
{
String iterator = (String) emu.nextElement();
properties.put(iterator,ht.get(iterator));
}
emu = ht2.keys();
while(emu.hasMoreElements())
{
String iterator = (String) emu.nextElement();
properties2.put(iterator,ht2.get(iterator));
}
try {
properties.store(new FileOutputStream("access.properties"),
null);
properties2.store(new FileOutputStream("users.properties"),
null);
} catch (Exception e) {
System.out.println(e.getMessage());
}
//usuwanie obiektow z sesji
session.removeAttribute("PrawaAll");
session.removeAttribute("Users");
session.removeAttribute(Constants.USER_KEY);
session.invalidate();
return (mapping.findForward(Constants.SUCCESS));
}
}
this code works on built in eclipse tomcat but dont work on ordinary tomcat
server
What's the error you are getting?
i dont get any errors in tomcat logs neither in localhost log nor stdout log
Note: When posting a question on usenet, its best to:
1. Describe the problem
I have an application which save own state to a properties files after user
logoff. It works when I did it on my computer on tomcat included in eclipse
IDE but it didnt work(dont save file) when i try deploy application on other
computer on ordinary tomcat. Tomcat doesnt let overwrite files or what??
Pls help
2. Show us what you did (i.e., complete compilable code).
class above
3. Tell us the error you are getting.
like i wrote above i dont get any
4. Tell us what you are expecting to happen.
i want to save a file or overwrite a file in tomcat webapp directory