Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Super Bronze

response.sendredirect

Hi

I've been patching up the speeddials.jsp xml service from the IPPhone SDK as it doesn't seem to compile out-of-the-box (or is there a likely step I'm missing? - problems seems to be that the done/delete buttons don't work and it uses xmlencoder in a way that no longer seems to work).

At any rate, I have it working, but have had to take this line out:

response.sendRedirect(thisPage + "&action=update&index=" + index);

in favour of sending back a CiscoIPPhoneExecute object to refer to the URL:

out.print("<CiscoIPPhoneExecute><ExecuteItem URL=");

out.print("\"" + thisPage + StringEscapeUtils.escapeXml("&action=update&index=") + index + "\"");

out.print("/></CiscoIPPhoneExecute>");

Do the phones not accept redirects?

If I use the redirect, it just displays 'Host Not Found'.

Thanks!

Aaron

Aaron Please remember to rate helpful posts to identify useful responses, and mark 'Answered' if appropriate!
6 REPLIES

Re: response.sendredirect

Hi there,

you must have JDK installed if you want to run/compile JSP pages (actually, JSP's just compile into servlets and then these servlets get executed, actually).

And, the Java samples that come with the SDK are... not too elegant. They are quite alright for a quick and dirty ehm solution, but there is a nicer way to do the job if you want to go the Java way.

For instance, the code fragment above is generating XML like Larry. out.println... come on...

- Stick to servlets (already compiled to Java bytecode, no surprises like compilation errors when deploying etc).

- use SAX or, if you are sure you have enough RAM installed, use DOM. There are many options to choose from, personally, I prefer SAX, but JDOM is a good option too.

Super Bronze

Re: response.sendredirect

Hi

I do have JDK installed (hence why the altered pages compile)... Also I know there are better ways to use XML but I'm doing the basics first..

The question I'm really interested in is why didn't the response.sendredirect work; is this just something the phone's browser doesn't support?

Thanks

Aaron

Aaron Please remember to rate helpful posts to identify useful responses, and mark 'Answered' if appropriate!
Community Member

Re: response.sendredirect

It appears that you have a relative URL in response.sendRedirect. I have used redirect and it worked fine. Web browser can understand relative URLS (/newPage.jsp), but for phones, you have to give complete URL (http://xx.xx.xx.xx/App/newPage.jsp). See the following JSP page that works fine on all phones:

<%@ page language="java" %>

<%@ page import="java.io.*, java.util.*, java.lang.*, java.net.*" %>

<%@ page import ="javax.servlet.*, javax.servlet.http.*" %>

<%

String thisPath = request.getRequestURI();

String thisContext = request.getContextPath();

String thisServer = InetAddress.getLocalHost().getHostAddress();

int thisPort = request.getServerPort();

String thisApp = "http://" + thisServer + ":" + thisPort + thisContext;

response.sendRedirect(thisApp+"/servlet/TransformXMLNL?file=/survey/surveylistPhoneXSL&xmlFile=/survey/surveyList.xml");

%>

Super Bronze

Re: response.sendredirect

Good suggestion; but the jsp I'm using does form the full URL:

String thisPage = "http://" + thisServer + ":" + thisPort + thisPath + "?name=" + deviceName;

Any more ideas?

Thanks

Aaron

Aaron Please remember to rate helpful posts to identify useful responses, and mark 'Answered' if appropriate!

Re: response.sendredirect

Hi,

would you mind posting the whole source code here? Thanks

Community Member

Re: response.sendredirect

Can you open it in the web browser and copy paste the XML you are getting?

172
Views
6
Helpful
6
Replies
CreatePlease to create content