兄弟,现在概念不太清楚。当然的先问清楚。
如果可以的话,那发送到客户端的只是applet的代码,
例如有一个数据项是用户可写的。我就的取出数据项中的数据放到输出流中。同时为客户端的applet添加text框。并将那些数据放在text显示(可以让客户修改)
可以使用代码text mytext=new text()。
将上面的代码发送到客户端,客户端可以正常显示马,哪样的代码可没有经过编译呀
如果可以的话,那发送到客户端的只是applet的代码,
例如有一个数据项是用户可写的。我就的取出数据项中的数据放到输出流中。同时为客户端的applet添加text框。并将那些数据放在text显示(可以让客户修改)
可以使用代码text mytext=new text()。
将上面的代码发送到客户端,客户端可以正常显示马,哪样的代码可没有经过编译呀
解决方案 »
- java命令模式
- DatagramPacket 的问题 在线等。。。
- java Swing 设置背景图片 高手看看我哪里错了? 谢谢
- 急!!!关于改变JTable显示的问题,好久没搞出来,达人帮我看下
- java 范形做为方法参数的应用中不能理解的问题,希望有高人指点迷津,谢谢```
- 请教高手一个问题,虽然我已无分可用,但请DX们务必帮忙啊!!
- 抽象类的问题~
- 如何得到键盘事件(KeyEvent)
- How to close the IE browser window which applet plugin
- 跪求判断等腰直角三角形
- 紧急问题:cloudview中怎么不能新建Database?
- 程序能编译,但是不能运行,怎么回事?
applets site:
private void defineOrgStruc(ArrayList levellist) throws MalformedURLException, IOException{
URL url = new URL(servleturl);
URLConnection con = url.openConnection();
con.setUseCaches(false);
System.out.println(levellist.toString());
try{
ObjectOutputStream outputToServlet = null;
con.setDoOutput(true);
outputToServlet = new ObjectOutputStream(con.getOutputStream());
outputToServlet.writeObject(levellist);
outputToServlet.flush();
outputToServlet.close();
}catch (IOException se){
JOptionPane.showMessageDialog(null, "Can not establish connection to server", "Connection failed", JOptionPane.PLAIN_MESSAGE);
return;
} try{
InputStream in = con.getInputStream();
ObjectInputStream objStream;
objStream = new ObjectInputStream(in);
objStream.readObject();
}catch(Exception re){
JOptionPane.showMessageDialog(null, "Can not establish connection to server", "Connection failed", JOptionPane.PLAIN_MESSAGE);
return;
}
JOptionPane.showMessageDialog(null, "Structure is saved!");
}
public class SaveOrgStrucServlet extends HttpServlet {
private static final String CONTENT_TYPE = "text/html";
//Initialize global variables
public void init() throws ServletException {
}
//Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>SaveOrgStrucServlet</title></head>");
out.println("<body>");
out.println("<p>The servlet has received a GET. This is the reply.</p>");
out.println("</body></html>");
}
//Process the HTTP Post request
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException{
System.out.println("Trying to save levels:"); ObjectInputStream inputFromApplet = null;
BufferedReader inTest = null;
try{
inputFromApplet = new ObjectInputStream(request.getInputStream());
ArrayList levelnamelist = (ArrayList)inputFromApplet.readObject();
ModelForecastData obj = new ModelForecastData();
obj.createOrgStucture(levelnamelist);
//CreateOrgStrucXML xmlobject =new CreateOrgStrucXML(levelnamelist); ObjectOutputStream servout = new ObjectOutputStream(response.getOutputStream());
servout.writeObject("done");
servout.flush();
servout.close();
}catch(Exception se){
System.out.println(se.getMessage());
}
}
//Clean up resources
public void destroy() {
}
}
it's free and easy to configure
you just only show the communication between servlet and Applet.
but my problem is how to add controlbox such as jlabel,TextField and so on to client Applet from server.
The code is not encoded .when client accept these .can the work well ?
can you give me a hand or some advice .I will appreciate you !