response.sendredirect

Unanswered Question
Mar 23rd, 2007
User Badges:
  • Super Bronze, 10000 points or more
  • Community Spotlight Award,

    Member's Choice, May 2015

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

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 3 (2 ratings)
Loading.
Gergely Szabo Fri, 03/23/2007 - 07:55
User Badges:
  • Green, 3000 points or more
  • Community Spotlight Award,

    Member's Choice, December 2015

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.


Aaron Harrison Sat, 03/24/2007 - 08:50
User Badges:
  • Super Bronze, 10000 points or more
  • Community Spotlight Award,

    Member's Choice, May 2015

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

msabir Sun, 03/25/2007 - 08:52
User Badges:
  • Bronze, 100 points or more

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");

%>

Aaron Harrison Mon, 03/26/2007 - 02:06
User Badges:
  • Super Bronze, 10000 points or more
  • Community Spotlight Award,

    Member's Choice, May 2015

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

Gergely Szabo Mon, 03/26/2007 - 02:14
User Badges:
  • Green, 3000 points or more
  • Community Spotlight Award,

    Member's Choice, December 2015

Hi,


would you mind posting the whole source code here? Thanks

msabir Mon, 03/26/2007 - 15:56
User Badges:
  • Bronze, 100 points or more

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

Actions

This Discussion