In Servlet, response.sendredirect using iPlanet
I'm from INIDIA. I have some problem in using response.sendRedirect. I'm using iPlanet application server. I tested on Java Web Server and it's working fine there but please advice me, how it'll work on iPlanet.
Thanks
Should work the same way. If you have an actual problem when you try it, let us know.
Similar Messages
-
how can I see whatever I print through System.out.println in my servlets when I use iplanet 4.1
Hi Nitin,
Look out the below link, Hope this helps you.
http://knowledgebase.iplanet.com/ikb/kb/articles/4235.html
http://knowledgebase.iplanet.com/ikb/kb/articles/4790.html
http://knowledgebase.iplanet.com/ikb/kb/articles/4699.html
Regards,
Dakshin.
Developer Technical Support
Sun Microsystems
http://www.sun.com/developers/support. -
Pass data from servlet to jsp using sendRedirect
Hi,
I am passing data from servlet to jsp using forward method of request dispatcher but as it doesn't change the url it is creating problems. When ever user refreshes the screen(browser refresh) it's re-loading both servlet and jsp, which i don't want to happen. I want only the jsp to be reloaded.
Can I pass data from servlet to jsp using sendRedirect in this case. I also want to pass some values from servlet to jsp but without using query string. I want to set some attributes and send to jsp just like we do for forward method of request dispatcher.
Is there any way i can send data using attributes(without using query string) using sendRedirect? Please let me knowsendRedirect is meant as a true redirect. meaning
you can use it to redirect to urls not in your
context....with forward you couldn't pass information
to jsps/servlets outside your own context.Actually, you can:
getServletContext().getContext("/other").getRequestDispatcher("/path/to/servlet").forward(request, response)I think the issue here is that the OP would like to have RequestDispatcher.forward() also update the address in the client's browser. That's not possible, AFAIK. By the time the request is forwarded, the browser has already determined the URL of the servlet, and the only I know of way to have the browser change the URL to the forwarded Servlet/JSP is to send a Location: header (i.e. sendRedirect()). Remember that server-side dispatching is transparent to the client. Maybe there's some tricky stuff you can do with JavaScript to change the address in the address bar without reloading the page?
Brian -
What referer we get if we use response.sendredirect
I have Message.jsp page .This has one form This form on submitting calls servelt.After completing processing Servelt redirect to Message.jsp .The code is
response.sendRedirect("Message.jsp");
When i get referer in Message.jsp using request.getHeader("Referer");
i get Message.jsp(not showing full path).
I want to know is it normal behavior bcoz what i expect referer should be servelt
Thanks VijayActually standard solution for this is confirming the TO with difference.
In this case the missing 2 PCS would go to storage type 999 and dynamic storage bin
address as your picking TO number.
When you finish the process you will have this situation:
- 3 PCS confirmed for your reservation
- 2 PCS sent to 999 storage type - "TO number" storage bin
- Then do a reversal of your material document for 2 PCS and close the reservation for the missing 2 PCS
- Close open transfer requirements, LL01 or LB11, or any LBxx that suits you
- Then you can clear the positive quantity from 999 by LI21 during Phys.Inv.
This should be clean and leaves no problems behind. -
Using iPlanet with XSQL Servlet
Anyone have any information on how to configure the XSQL Servlet to work with iPlanet?
TIAIt won't work because iPlanet 4.1 has a broken implementation of the Servlet API's getRealPath() method, the method that XSQL Servlet uses to resolve virtual paths into absolute paths.
I just debugged a complaint that it didn't work with iPlanet this week and this was the result I found.
Their path resolution works for their own JSP implementation, but not for any other servlet. -
Calling a bean in weblogic 4.5 from a servlet which is in Iplanet webserver4.1
while Calling a bean in weblogic 4.5 from a servlet which is in Iplanet webserver4.1 sometimes the servlet is not able to call the bean. There is no error logged in webserver. This is happening very rarely and when it happens I have to shut and restart IplanetWS.
Can anyone tell me some solution or reason
Regards
NitinWe did receive a 4.5.1 / 5.1 interoperability patch - but it wasn't quite 'seamless'.
We never tried to use it.
SOAP? Isn't that around 50 times slower than RMI?
Mike
"Gary Mui" <[email protected]> wrote:
We ran into this issue last fall and got some feedback from weblogic
support. They originally said that it could be done (as well as different
versions talking to one another via JMS) but it turned out that they
were
incorrect and ended up saying that it is not possible. Before 6.0 went
GA,
BEA said that there would be a interoperability patch to do this, but
I've
never seen nor heard of anything regarding it. As a workaround, we
implemented 4.5.1 / 6.0 communication via SOAP.
Mike Reiche wrote in message <3b1bcaec$[email protected]>...
I have the same question - and more. Last year we were told that wecould
not use
RMI (and ejbs) between 4.5.1 and 5.1. Which seems kinda weird becauseI've
heard
of people using WL ejbs from Tomcat. This issue has caused us to avoidusing
WL ejbs in any future development which has any chance of ever beingused
by any
app server (WL included) that is not under the direct control of thedata
center.
I've been trying to convince the Architecture team here that we canuse WL
EJBs
and we can call them from other app servers - but can't seem to getany
supporting
statement from BEA (maybe I haven't tried hard enough).
Anyway, a response from BEA would be appreciated.
- Mike
"Madhu K" <[email protected]> wrote:
Is it possible to call a (stateless session) bean deployed in weblogic
6.0
from a bean in weblogic 5.1? I have two versions of weblogic running
on two
different hosts and I have to call a bean that is running in 6.0 from
5.1.
Are there any limitations?
Appreciate any feedback/suggestions.
Thanks,
Madhu -
IOException - WEB8001 - when writing to servlet response outputstream
I am attempting to port a Java servlet application from iws 6.0 to 6.1, sp2, but am encountering IOExceptions during load testing.
The servlet composes its response in a character array, and then calls the following method to write the characters to the servlet response object:
static void writeResponse( HttpServletResponse response, char[] chars, String charset ) throws IOException {
OutputStreamWriter writer =
new OutputStreamWriter( response.getOutputStream(), charset );
char[] buffer = new char[8192];
CharArrayReader reader = new CharArrayReader( chars );
int read = 0;
while(( read = reader.read( buffer, 0, 8192 )) > -1 )
writer.write( buffer, 0, read );
writer.close();
}Under moderate load (2-4 simultaneous connections), an IOException will sometimes be thrown. The stack dump is:
java.io.IOException: WEB8001: Write failed
at com.iplanet.ias.web.connector.nsapi.NSAPIConnector.write(NSAPIConnector.java:750)
at com.iplanet.ias.web.connector.nsapi.NSAPIResponseStream.write(NSAPIResponseStream.java:74)
at org.apache.catalina.connector.ResponseBase.flushBuffer(ResponseBase.java:765)
at org.apache.catalina.connector.HttpResponseBase.flushBuffer(HttpResponseBase.java:779)
at com.iplanet.ias.web.connector.nsapi.NSAPIResponse.flushBuffer(NSAPIResponse.java:127)
at org.apache.catalina.connector.ResponseBase.write(ResponseBase.java:738)
at org.apache.catalina.connector.ResponseStream.write(ResponseStream.java:325)
at sun.nio.cs.StreamEncoder$CharsetSE.writeBytes(StreamEncoder.java:336)
at sun.nio.cs.StreamEncoder$CharsetSE.implWrite(StreamEncoder.java:395)
at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:136)
at java.io.OutputStreamWriter.write(OutputStreamWriter.java:191)
at eng.pubs.servlet.DocServlet.writeResponse(DocServlet.java:1034)The exception is not thrown consistently for any given URL, but appears to be random. When run under iws 6.0, the exceptions do not occur at all. Most of the time, the method will have written 32K
of data when the exception is thrown.
Any clues about how I might debug this?What are you using as your test client?The test client is WebStone 1.0. WebStone always downloads the whole response, and reports the size of the response in bytes. From this I can see that when the IO exception occurs, webstone is unable to read the whole response, as it reports a smaller size.
So, I do not think the problem is that the client has prematurely aborted its download. WebStone doesn't work that way. I think something has gone awry on the server side, and this worries me. -
Response.sendRedirect() from doEndTag() method
Hi there,
I am trying to call response.sendRedirect("url") in a custom tag doEndTag() method but for or some reason I cannot get access to the javax.servlet.http.HttpServletResponse object where this method lives. Does anyone know how I can do a response.redirect from a doEndTag() method? I've searched the forum and it appears other people can do it but I'm not sure how?
I can get access to javax.servlet.ServletResponse object by using pageContext.getResponse() but that doesn't give me the response.sendRedirect method. Can anyone help? What am I doing wrong?
Thanks for your help.
Cheers,
Brent.you can pass the response object as argument to your
method..Thanks for your response!
Unfortunately I can't change the doEndTag() method parameters as doEndTag() is defined in the Tag interface. But if you mean pass the response object as an attribute of the tag i suppse that is possible.
However, that's pretty close to the hack I currently have to work around this problem except I'm putting the response object in a request attribute in the page and then retrieving it in the doEndTag() method.
But I am after something a little cleaner than either of these options..... I'm hoping I can just get the response object from another object I have access to. Any more thoughts? -
Hi,
Here are the steps to reproduce the problem with the examplesWebApp application
bundled with wlserver6.0(sp2):
Product: Weblogic server 6.0 (sp2)
Browser: IE 5.0
1. Add index.jsp as the welcome file in WEB-INF/web.xml
2. Create index.jsp as below:
<%
response.sendRedirect("index.html");
return;
%>
<html>
<head>
<title>Index JSP file</title>
</head>
<body>
<font color="red">This is index.jsp file </font>
</body>
</html>
3. Create index.html as below:
<html>
<head>
<title>Index HTML file</title>
</head>
<body>
<font color="red">This is index.html file </font>
</body>
</html>
4. Run the examples server and make sure examplesWebApp is deployed on the examples
server using the console
5. Access the URL http://localhost:7001/examplesWebApp
The page will display a compilation error as below:
C:\bea\wlserver6.0\config\examples\applications\examplesWebApp\WEB-INF\_tmp_war_examplesServer_examplesServer_examplesWebApp\jsp_servlet\_index.java:89:
unreachable statement
out.print("\r\n<html>\r\n<head>\r\n<title>Simple html</title>\r\n</head>\r\n<body>\r\n<font
color=\"red\">This is index.jsp page</font>\r\n</body>\r\n</html>\r\n");
^
and a look at the generated java code for index.jsp (_index.java) will reveal
the erroneous code snippet below in the jsp service method:
try { // error page try block
//[ /index.jsp; Line: 1]
response.sendRedirect("index.html"); //[ /index.jsp; Line: 2]
return; //[ /index.jsp; Line: 3]
out.print("\r\n<html>\r\n<head>\r\n<title>Simple html</title>\r\n</head>\r\n<body>\r\n<font
color=\"red\">This is index.jsp page</font>\r\n</body>\r\n</html>\r\n");
} catch (Exception __ee) {
while (out != null && out != _originalOut) out = pageContext.popBody();
pageContext.handlePageException(__ee);
The above web application works fine in Tomcat 3.2.X environment. The Weblogic
server 6.0 servlet engine should not generate the "out.println()" corresponding
to the html section of index.jsp. The moment it sees the "return", it should stop
processing further.
Can someone from Weblogic support team please verify this and let me know when
this bug will be fixed?
One interesting thing I noticed was when we last tried weblogic 6.0 at its beta
stage, it worked fine after we put in a special patch jar file called "redirectfix.jar"
we received from weblogic team but somehow it got re-introduced by the time it
was released!!
We are planning to migrate our product from tomcat 3.2.x to weblogic 6.0. Our
product has a lot of pages with such conditional {response.sendRdirect("page.jsp");return;}
blocks. We would really appreciate a faster response form weblogic team.
Thanks in advance.
sam...
Sam Palanisamy
Senior Software Engineer
Manage.com
2345 N. First Street First Floor
San Jose CA 95131
Why should it stop when it sees a return? Is that in the spec?
Peace,
Cameron Purdy
Tangosol Inc.
<< Tangosol Server: How Weblogic applications are customized >>
<< Download now from http://www.tangosol.com/download.jsp >>
"Sam Palanisamy" <[email protected]> wrote in message
news:[email protected]...
>
> Hi,
>
> Here are the steps to reproduce the problem with the examplesWebApp
application
> bundled with wlserver6.0(sp2):
>
> Product: Weblogic server 6.0 (sp2)
> Browser: IE 5.0
>
> 1. Add index.jsp as the welcome file in WEB-INF/web.xml
>
> 2. Create index.jsp as below:
> <%
> response.sendRedirect("index.html");
> return;
> %>
> <html>
> <head>
> <title>Index JSP file</title>
> </head>
> <body>
> <font color="red">This is index.jsp file </font>
> </body>
> </html>
>
> 3. Create index.html as below:
> <html>
> <head>
> <title>Index HTML file</title>
> </head>
> <body>
> <font color="red">This is index.html file </font>
> </body>
> </html>
>
> 4. Run the examples server and make sure examplesWebApp is deployed on the
examples
> server using the console
>
> 5. Access the URL http://localhost:7001/examplesWebApp
>
> The page will display a compilation error as below:
>
C:\bea\wlserver6.0\config\examples\applications\examplesWebApp\WEB-INF\_tmp_
war_examplesServer_examplesServer_examplesWebApp\jsp_servlet\_index.java:89:
> unreachable statement
> out.print("\r\n<html>\r\n<head>\r\n<title>Simple
html</title>\r\n</head>\r\n<body>\r\n<font
> color=\"red\">This is index.jsp page</font>\r\n</body>\r\n</html>\r\n");
> ^
>
> and a look at the generated java code for index.jsp (_index.java) will
reveal
> the erroneous code snippet below in the jsp service method:
>
> try { // error page try block
>
> //[ /index.jsp; Line: 1]
> response.sendRedirect("index.html"); //[ /index.jsp; Line: 2]
> return; //[ /index.jsp; Line: 3]
> out.print("\r\n<html>\r\n<head>\r\n<title>Simple
html</title>\r\n</head>\r\n<body>\r\n<font
> color=\"red\">This is index.jsp page</font>\r\n</body>\r\n</html>\r\n");
> } catch (Exception __ee) {
> while (out != null && out != _originalOut) out =
pageContext.popBody();
> pageContext.handlePageException(__ee);
> }
>
> The above web application works fine in Tomcat 3.2.X environment. The
Weblogic
> server 6.0 servlet engine should not generate the "out.println()"
corresponding
> to the html section of index.jsp. The moment it sees the "return", it
should stop
> processing further.
>
> Can someone from Weblogic support team please verify this and let me know
when
> this bug will be fixed?
>
> One interesting thing I noticed was when we last tried weblogic 6.0 at its
beta
> stage, it worked fine after we put in a special patch jar file called
"redirectfix.jar"
> we received from weblogic team but somehow it got re-introduced by the
time it
> was released!!
>
> We are planning to migrate our product from tomcat 3.2.x to weblogic 6.0.
Our
> product has a lot of pages with such conditional
{response.sendRdirect("page.jsp");return;}
> blocks. We would really appreciate a faster response form weblogic team.
>
> Thanks in advance.
> sam...
> Sam Palanisamy
> Senior Software Engineer
> Manage.com
> 2345 N. First Street First Floor
> San Jose CA 95131
>
>
-
HTTP error 302: response.sendRedirect()
Hi everybody,
I have a first servlet (AGSenderServlet) sending a file to a second one (AGReceiverServlet). This second servlet I'm receiving a file and then redirect to a JSP page. But I'm getting the following exception:
13-Sep-2010 13:20:42 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet AGSenderServlet threw exception
java.io.IOException: Received HTTP status code 302
at AGSenderServlet.doGet(AGSenderServlet.java:43)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
....I've looked on internet and apparently the error 302 is linked to response.sendRedirect().
Here is my code:
public class AGReceiverServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
// Create a factory for disk-based file items
DiskFileItemFactory factory = new DiskFileItemFactory();
// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload(factory);
String realPath = this.getServletContext().getRealPath("sync/in");
List items = null;
try {
items = upload.parseRequest(request);
} catch (FileUploadException e) {
e.printStackTrace();
// Process the uploaded items
Iterator iter = items.iterator();
try {
String fileName = "blabla";
while (iter.hasNext()) {
FileItem item = (FileItem) iter.next();
// Process a file upload
if (!item.isFormField()) {
fileName = item.getName();
long sizeInBytes = item.getSize();
//Write to File
if (fileName != null) {
fileName = FilenameUtils.getName(fileName);
File uploadedFile = new File(realPath);
if (!uploadedFile.exists())
uploadedFile.mkdirs();
uploadedFile = new File(realPath+"/"+fileName);
item.write(uploadedFile);
System.out.println("http://"+request.getServerName()+':'+request.getServerPort()+"/upTool/filereceived.jsp?filename="+fileName);
String redirectURL = "http://"+request.getServerName()+':'+request.getServerPort()+"/upTool/filereceived.jsp?filename="+fileName;
response.sendRedirect(redirectURL);
} catch (Exception e) {
e.printStackTrace();
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}The file received is saved properly and is ok.
Using print out I have discovered that it was the running the whole code but not the code in filereceived.jsp (the JSP of the sendRedirect() ).
I have tried the url used in the sendRedirect() and it works ok.
Any idea?
Cheers.The AGSenderServlet is sending a file to the AGReceiverServlet using multipart and Postmethod object. Here is the code.
public class AGSenderServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
String filename = request.getParameter("filename");
String ext = request.getParameter("ext");
String serverName = request.getParameter("serverName");
String port = request.getParameter("port");
String path = null;
String uri = "http://"+serverName+":"+port+"/AGReceiverServlet";
File file = new File((this.getServletContext().getRealPath("/sync/out"))+"\\"+filename+'.'+ext);
System.out.println("Test = "+file.getAbsolutePath());
PostMethod post = new PostMethod(uri);
Part[] parts = new Part[] {
new FilePart(file.getName(), file) // File you want to upload
post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
// Now perform the POST and check for errors
HttpClient http = new HttpClient();
int status = http.executeMethod(post);
if (status != HttpStatus.SC_OK) {
throw new IOException("Received HTTP status code " + status);
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}Line 43 is just throw new IOException("Received HTTP status code " + status);What do you mean by " then you should handle it." ? I think I handle it. It redirects to the JSP filereceived.jsp which is hosted and available on the server (tried to access it directly by entering the url and it works).
Edited by: Foobrother on Sep 13, 2010 7:38 AM -
6.1 SP5: response.sendRedirect crashes
Hi all,
I am porting a JSP app from Iplanet 4.1 to SunONE 6.1 SP5 (Solaris 5.9).
When I try to do the above statement in a JSP, I get the following in the error log:
[14/Jun/2007:16:05:05] failure ( 3812): for host 172.16.10.184 trying to POST /jspcontent/ozbet.jsp;jsessionid=43DBC3EA6343C4B0E3BF6AD26B943D25, service-j2ee reports: StandardWrapperValve[jsp]: WEB2792: Servlet.service() for servlet jsp threw exception
java.lang.IllegalStateException
at org.apache.catalina.connector.HttpResponseFacade.sendRedirect(HttpResponseFacade.java:179)
at jsps.jspcontent._ozbet_jsp._jspService(_ozbet_jsp.java:109)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
at com.iplanet.ias.web.jsp.JspServlet$JspServletWrapper.service(JspServlet.java:687)
at com.iplanet.ias.web.jsp.JspServlet.serviceJspFile(JspServlet.java:459)
at com.iplanet.ias.web.jsp.JspServlet.service(JspServlet.java:375)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:771)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:322)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:209)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:161)
at com.iplanet.ias.web.WebContainer.service(WebContainer.java:580)
I am not sure what I need to declare differently in 6.1. The web app jars are in WEB-INF/lib under the docroot.
The code in the JSP is pretty standard, but ran under Iplanet 4.1.
try {
String URL = "https://www.ozbet.com.au/tab/ozbet.htm?p_date=" //has parameters;
response.sendRedirect(URL);
catch (ApplicationException e) {
//do some stuff here
%>
<b>ERROR:</b> <%= msg %>"
<%
FYI the webapp is working fine wrt to jdbc, jsp etc. It is just the sendRedirect() that is crashing.
Do I need to declare anything related to NSAPI in obj.conf ?
Please help and thanks in advance.
Richard
Message was edited by:
r_defonseka
Message was edited by:
r_defonsekaThat's not a crash. HttpServletResponse.sendRedirect is throwing an IllegalStateException because you called it after the response had been committed. This is a documented part of the Servlet spec. (See, for example, http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServletResponse.html#sendRedirect(java.lang.String) for the the J2EE 1.3 docs.)
The most likely problem is that you're calling sendRedirect after an include or after outputting too much data. If you're going to call sendRedirect, you need to do so near the top of your JSP file, before you output a lot of data. Once data has been sent to the client, there's no way for the server to say "oops, never mind, ignore that data and redirect over here instead". -
Sending Javascript call in servlet response.
I am calling a servlet from a javascript ( .js) file. Based on the status of the server I want send javascript function call to the client browser.
Is it possible?
Here is what I am trying to do :
response.sendRedirect("javascript:myfinction()");
myfunction() is defined in the source .js file from where I am calling the servlet.
Hope you understand what I am trying to do. Please help.
Thanks
PradipThat won't be possible as the servlet executes first on the server, then javascript executes on the client.
Remember that Javascript requires the browser to do anything, it's the browser functionality that it runs in. The servlet executes on the server, then forwards to the client, and therefore has no access to javascript whatsoever, at least not in the context that you're speaking of. By the time javascript is ready to start, the servlet has already completed.
If it was the other way around, that would be possible (i.e. use JSP/Servlet to set javascript variable value).
Sorry. -
Response.sendRedirect throws IOException
I am using jsdk2.0 and I am using servlet runner to test this servlet.
In my servlet if a person is authorized I am sending the person to a particular URL.
if(rs.next())
response.sendRedirect(response.encodeRedirectUrl("https://xyz.com"));
It does go to the URL but It throws a exception which I can see in the servlet runner... IT Says java.io.IOException: Tried to write more than the content length..
sun.servlet.HttpOutputStream.check(HttpOutputStream:java:282)..Dont have a 282 line...
Can someone tell me...I know I am using deprecated method but why is it giving an exception?your using https which is not supported by sendRedirect as far a i know. There is a special package for ssl afaik.
-
Should I return after a response.sendRedirect?
I have this code in the beggining of my JSP page and it seems to work okay. My question is: is it okay to use the return keyword in a JSP page or does it cause problems. Would this practice be considered safe?
<%@page import="javax.sql.*,javax.naming.*" %>
<%
// Don't let the browser cache this
response.setHeader("cache-control", "no-cache");
response.setHeader("pragma","no-cache");
response.setIntHeader("expires", -1);
%>
<%
// Determine if this web application is properly configured
boolean notConfigured = false;
Context i = new InitialContext();
DataSource ds = (DataSource) i.lookup("java:comp/env/sqlServer");
if (ds==null) notConfigured = true;
i.close();
String dataBase = application.getInitParameter("database");
if (dataBase == null) notConfigured = true;
if (notConfigured)
response.sendRedirect("notConfigured.jsp");
return;
%>Since the JSP gets converted into a Servlet and whatever code that you write in your JSP effectively goes into the service() method of the generated servlet, it may not be appropriate to call return. This will not give any chance for the rest of the code (may be for cleanup) that may have been inserted by the JSP -> Servlet converter (or whatever it is called) to be executed.
However, I am not 100% sure on this. Very much interested to know more about this from somebody more knowledgeable on this.
Jay -
Response sendRedirect is not working in JSF
Hi,
I am getting an error on calling response.sendRedirect() method in my backing bean. This piece of code is for redirecting:
if (userCredentials.isExpired() || userCredentials.isInThreshold() ) { // Just checking for some boundary conditions
ViewHandler vh = ctx.getApplication().getViewHandler();
String viewUrl = vh.getActionURL(ctx, PATH_FOR_CHANGE_USER_PAGE);
ExternalContext ectx = ctx.getExternalContext();
HttpServletResponse response =
(HttpServletResponse)ectx.getResponse();
response.sendRedirect(viewUrl); /// This is where the error is thrown.
}Here is the stack trace:
SEVERE: Error Rendering View[/xhtml/home/AppHomePage.xhtml]
javax.faces.el.EvaluationException: /layout/header.xhtml @27,78 value="#{UserInformation.userName}": Error getting property 'userName' from bean of type com.mrc.web.infrastructure.login.UserInfo: java.lang.IllegalStateException: Response has already been committed, be sure not to write to the OutputStream or to trigger a commit due to any other action before calling this method.
at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:60)
at javax.faces.component.UIOutput.getValue(UIOutput.java:167)
at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:102)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:221)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:199)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:740)
at org.apache.myfaces.trinidad.render.CoreRenderer.encodeChild(CoreRenderer.java:304)
at org.apache.myfaces.trinidad.render.CoreRenderer.encodeAllChildren(CoreRenderer.java:321)
at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.PanelPartialRootRenderer.renderContent(PanelPartialRootRenderer.java:64)
at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.BodyRenderer.renderContent(BodyRenderer.java:142)
at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.PanelPartialRootRenderer.encodeAll(PanelPartialRootRenderer.java:119)
at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.BodyRenderer.encodeAll(BodyRenderer.java:78)
at org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd(CoreRenderer.java:224)
at org.apache.myfaces.trinidad.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:693)
at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:252)
at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:249)
at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:594)
at org.apache.myfaces.trinidadinternal.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:182)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:137)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:214)
at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._invokeDoFilter(TrinidadFilterImpl.java:262)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:219)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:173)
at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:644)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:391)
at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:908)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:458)
at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:226)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:127)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:116)
at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:234)
at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:29)
at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:879)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
at java.lang.Thread.run(Thread.java:595)
*Caused by: java.lang.IllegalStateException: Response has already been committed, be sure not to write to the OutputStream or to trigger a commit due to any other action before calling this method.*
at com.evermind.server.http.EvermindHttpServletResponse.sendRedirect(EvermindHttpServletResponse.java:1545)
at javax.servlet.http.HttpServletResponseWrapper.sendRedirect(HttpServletResponseWrapper.java:170)
at com.sun.faces.context.ExternalContextImpl.redirect(ExternalContextImpl.java:357)
at org.apache.myfaces.trinidad.context.ExternalContextDecorator.redirect(ExternalContextDecorator.java:253)
at com.mrc.web.infrastructure.login.UserInfo.getPasswordThreshold(UserInfo.java:547)
at com.mrc.web.infrastructure.login.UserInfo.getUserName(UserInfo.java:231)
at sun.reflect.GeneratedMethodAccessor196.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.sun.faces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:99)
at com.sun.facelets.el.LegacyELContext$LegacyELResolver.getValue(LegacyELContext.java:141)
at com.sun.el.parser.AstValue.getValue(AstValue.java:96)
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:183)
at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:56)
... 39 moreI dont think i am calling the 'sendRedirect' method anywhere before this code(if i understood the error message).
Please help me with some pointers.
Thanks,
Srikanth
Edited by: sriki79 on Jul 26, 2010 5:06 PM
Edited by: sriki79 on Jul 26, 2010 5:06 PM
Edited by: sriki79 on Jul 26, 2010 5:07 PMYep, content has already been flushed to the browser and then the redirect cannot work anymore. Move the redirect logic to a filter I'd say.
Maybe you are looking for
-
Sending email to multiple address using Utl_Smtp
Hi, I want to send email to multiple address using the Utl_Smtp feature. When I am sending email to one email address in the To:Field it works fine.However, when I send to multiple address I am getting the below error.I am using a table(Email_test) t
-
CAMERA RAW UNABLE TO SAVE TO A DIFFERENT LOCATION.
I recently installed PS CS 5, and am having a problem with Camera Raw. I cannot save any type of image to a different location from Camera Raw. I CAN save to the same folder from which I opened the original file. Problem exists with any file formats,
-
How can I play downoaded videos from my Mac Mini on my TV which is connected with an HDMI?
-
Applescript to play Quicktime Movie
Hey guys TOTAL NEWBIE to Applescript. Details: OS 10.5.8 Quicktime Pro 7.6.9 I want an audio program I use called Mainstage to "play" whatever QT movie I have loaded up in QT. Mainstage has example scripts for iTunes, and here is an exact copy of wha
-
Customisation of F4 for material search
dear all, while creating a sales order, when i enter material in line item, i want to customise search i.e. F4 i want to search material on two criteria at a time 1) material type 2) material group. please give solution