• Post Reply Bookmark Topic Watch Topic
  • New Topic

Redirect issue

 
Ajith Prasad
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
using response.sendRedirect("xyz.jsp"); works fine on windows machine
but when we use the same code the page is not redirecting in Linux machine.
could any one help me
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please send us the error message you've got in Linux.
 
Ajith Prasad
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the sample code that i wrote here,

If we write response.sendRedirect("") at the bottom of the try catch block, the page doesn't redirect in Linux Machine(code does not throw any exceptions),However
in Windows Machine,It Works Fine.Is this issue caused by the try catch block?



try {

File f = new File("");

if(f.exists())
{
long fileLength = f.length();
RandomAccessFile raf = new RandomAccessFile(f, "rw");
raf.seek(fileLength);
raf.writeBytes("testfile");
raf.writeBytes("\n");
raf.close();
}
else
{
f.createNewFile();
FileWriter ff=new FileWriter(f);
ff.write("testfile");
ff.write("\n");
ff.flush();
ff.close();
}

}catch(Exception ee){}

response.sendRedirect("");
System.out.println("The Result si :"+ rec);
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Are you using the same container under Windows and Linux ?
2. What is the blank url in sendRedirect("") ?
3. Please send the error message. If you don't describe what is happening, it is difficult to help. "The page doesn't redirec". What is it doing then ? Did you check the container's log file ?
 
Ajith Prasad
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Are you using the same container under Windows and Linux ?

Yes

2. What is the blank url in sendRedirect("") ?

response.sendRedirect("Claim.jsp");

3. Please send the error message. If you don't describe what is happening, it is difficult to help. "The page doesn't redirec". What is it doing then ? Did you check the container's log file ?
Say, I have reDirect to Claim.jsp from reqq.jsp
While redirecting , It Displays the Blank Page and the URL Stands on reqq.jsp.(NO action is taking place)
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nothing ? Not even errors in Tomcat's log ?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You didn't answer the question about the log files.
Did your code reach the System.out.println statement at the end?
 
Ajith Prasad
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the Exception Written on the log file

8/23/06 10:25 AM defaultWebApp: JspServlet: unable to dispatch to requested page: java.io.FileNotFoundException: C:\oc4j\j2ee\home\default-web-app\Claim276Result.jsp (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:59)
at oracle.jsp.provider.JspFilesystemResource.fromStream(JspFilesystemResource.java:153)
at oracle.jsp.provider.JspFilesystemResource.fromReader(JspFilesystemResource.java:169)
at oracle.jsp.runtimev2.JspPageCompiler.fromReader(JspPageCompiler.java:345)
at oracle.jsp.runtimev2.JspPageCompiler.attemptCompilePage(JspPageCompiler.java:250)
at oracle.jsp.runtimev2.JspPageCompiler.compilePage(JspPageCompiler.java:171)
at oracle.jsp.runtimev2.JspPageInfo.compileAndLoad(JspPageInfo.java:338)
at oracle.jsp.runtimev2.JspPageTable.compileAndServe(JspPageTable.java:481)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:255)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:407)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:330)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:696)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:281)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:766)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:107)
at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:802)
at java.lang.Thread.run(Thread.java:479)
 
Ajith Prasad
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But when we place the response.sendRedirect("SomePage.jsp") on top of the try catch block, it works fine on both the machine(Linux and Windows).
(I tried with the Trial and Error Method.).But I couln't understand the flow behind it.Will the code after the sendRedirect("SomePage.jsp") execute? or the control tranfer over to the page that we specified in the
reDirect() method.Give Explanation Please.
 
Paul Clapham
Sheriff
Posts: 21882
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by ajith prasad:
But I couln't understand the flow behind it. Will the code after the sendRedirect("SomePage.jsp") execute?
Of course it will.

Explanation: the code is written in Java, and that is how Java works. After the sendRedirect() method completes, the next line of code after that will be executed. The servlet specification doesn't produce any new Java syntax that can make a method into a magic secret go-to statement. If this isn't obvious to you once put that way, you could put in a logging statement after the call to sendRedirect() and confirm that it is executed.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A wild guess.
You're not trying to redirect to the file you are creating in the else{} block, are you ? If you are, imagine that an exception happens (a common one is no permission to access the directory in write mode). You're catching the exception, doing nothing, and redirecting to the file that has not been created.
 
Ajith Prasad
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much for explaining my doubts out of your busy schedule.Thanks again for Paul and satou .

Another Clarification Please..

How much information that a session can store?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!