Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!

Larry Cryderm

Greenhorn
+ Follow
since Mar 23, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Larry Cryderm

another idea....the path to the file, did you use double "\" ? Like:
String myFile = "C:\\myDir1\\myDir2\\myFile.txt";
.....that'll bite you.
also, off the File object show the file.getAbsolutePath() .....so you can confirm you're pointing to where you want.
15 years ago
I can't see any reason your read should not work. I read and write XML files into my servlets all the time. Could it be permissions on the file? Can you open the file in any other app?
15 years ago
I'm trying to use hprof to dump data on my servlet's performance. The servlet runs under iPlanet Web Server 6.0. I've tried a slew of options and the only ascii data that dumps is the 'Thread START' section. If I output binary format I get more data, but the Heap Analysis Tool (HAT) seems to be broke for jdk 1.4.2. If I get the ascii output I can use many tools to assess the data (JPM is very good)...any ideas and Thanks!
16 years ago
I thought of that, but didn't know if serialization was involved.
Do you have a recommendation?
Thanks.
16 years ago
Has anyone successfully forwarded a request and response to a servlet residing on a different server?

We have multiple servers and want to forward some requests to a specific server. All servers run Servlets.

I thought this would work
request.getRequestDispatcher("urlToOtherServer").forward(request, response);
...but what I read is that this will only work on the same server.

I didn't want to open a URL and URLConnection to do this.

Any help or ideas appreciated.
16 years ago
Yup...the Commons API is full feature HTTP client stuff...didn't know it was out there, Thanks!
16 years ago
Check out the servlet code the jsp creates (in the *.java file). Emulate that code in your servlet to set the values. Remember, jsp's turn into servlets and those "short cuts" in jsp code are expanded in the servlet that is executed.
16 years ago
consider doing an HTTP forward to SERVLET2
...in SERVLET1 try:

public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {

try{
if(logged_in){
RequestDispatcher rd = request.getRequestDispatcher("SERVLET2_url");
rd.forward(request, response);
}
}
catch(Exception e){

e.printStackTrace();

}

}// end doPost
16 years ago
...this is what I use as a client that 'tunnels' into a listening servlet, hope it helps:
java.net.URL url = new java.net.URL(your_target_url_string);

java.net.URLConnection con = url.openConnection();

con.setUseCaches(false);
con.setDoOutput(true);
con.setDoInput(true);

con.setRequestProperty("Content-Type", "text/xml; charset=utf-8");

DataOutputStream out = new DataOutputStream(con.getOutputStream());

out.write(your_string_to_send.getBytes()); // WRITE to the site

out.flush();

BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(con.getInputStream()));
StringBuffer sb = new StringBuffer();
while ((inputLine = bufferedreader.readLine()) != null) {
sb.append(inputLine); // READ from the site
}
16 years ago