【发布时间】:2011-02-12 21:14:37
【问题描述】:
我在 Google App Engine 的数据存储中有以下类对象,我可以从“数据存储查看器”中看到它们:
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
@PersistenceCapable(identityType=IdentityType.APPLICATION)
public class Contact_Info_Entry implements Serializable
{
@PrimaryKey
@Persistent(valueStrategy=IdGeneratorStrategy.IDENTITY)
Long Id;
public static final long serialVersionUID=26362862L;
String Contact_Id="",First_Name="",Last_Name="",Company_Name="",Branch_Name="",Address_1="",Address_2="",City="",State="",Zip="",Country="";
double D_1,D_2;
boolean B_1,B_2;
Vector<String> A_Vector=new Vector<String>();
public Contact_Info_Entry() { }
......
}
我的 java 应用程序如何从 servlet url 获取对象?例如,如果有一个 Contact_Info_Entry 实例,其 Contact_Id 为“ABC-123”,而我的 App Id 为:nm-java
当我的java程序访问url时:
"http://nm-java.appspot.com/Check_Contact_Info?Contact_Id=ABC-123
Check_Contact_Info servlet 如何从数据存储中获取对象并将其返回到我的应用程序?
public class Check_Contact_Info_Servlet extends HttpServlet
{
static boolean Debug=true;
public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException
{
}
...
protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException { doGet(request,response); }
}
对不起,我需要更具体,如何在响应中发送对象?
public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException
{
PrintWriter out=response.getWriter();
Contact_Info_Entry My_Contact_Entry;
... get My_Contact_Entry from datastore ...
??? How to send it out in the "response" ???
}
弗兰克
【问题讨论】:
标签: google-app-engine servlets object