• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Peter Rooke
  • Himai Minh
Bartenders:
  • Piet Souris
  • Mikalai Zaikin

HttpServletResponse obj lost after using System.getProperty

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In "MyServlet.java" 's doGet method, I called another class's method which utilizes the following codes
FileInputStream file = new FileInputStream("inputFile"); Properties p = System.getProperties();
p.load(file);
System.setProperties(p);
String var = System.getProperty("VAR");
...
....
Notice the above codes are in ANOTHER class's method and "MyServlet.java" just called it, but I found immediately after it calls this method, the HttpServletResponse object is no longer functioning properly. For example,
response.sendRedirect("URL");
has not ANY effect at all.
By the way, i found the "var" does get the correct results. So the "System.getProperty()" does get right result.
Do you know what's the reason for the response object's lost ?
Thanks lot,
Ian
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My first thought was this:

The API for setProperties suggests that whatever is inside the System properties 'bag' is replaced (overwritten) by the one you are setting.

However, this doesn't appear to be the case, in fact, sending null into the setProperties method doesn't appear to make the current set of properties be forgotten.

I can't duplicate your condition. My property file contains one mapping hello=world. Here is my code for the 'helper' class Here is the servlet:The output is: And I get to done.jsp to boot.
[ February 26, 2002: Message edited by: Mike Curwen ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic