03-23-2007 03:14 AM - edited 03-13-2019 04:00 PM
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
03-23-2007 07:55 AM
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.
03-24-2007 08:50 AM
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
03-25-2007 08:52 AM
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");
%>
03-26-2007 02:06 AM
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
03-26-2007 02:14 AM
Hi,
would you mind posting the whole source code here? Thanks
03-26-2007 03:56 PM
Can you open it in the web browser and copy paste the XML you are getting?
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide