▓高分请教▓ 关于Jsp的后台操作如何实现?

passren 2003-09-14 01:31:30
我在jsp中想通过url来连接到远程的url jsp页面上实现其操作,同时不需要它返回任何东西这边的页面可以继续执行,怎么来实现这样的后台操作?
我觉的用url来调用可以实现,但不知道具体怎么实现!
...全文
66 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
swinging 2003-09-16
  • 打赏
  • 举报
回复
我估计你是想不刷新页面来进行后台操作,
如果是这样的话,我建议你使用XML,完全没有这么复杂。
Yssss1980 2003-09-15
  • 打赏
  • 举报
回复
大家的方法太不专业了,我来

import java.net.HttpURLConnection;
import java.net.URL;
import java.io.*;
import java.util.*;

public class ServiceProxy
{
private ServiceProxy(){ }

static public String request(URL url) throws IOException
{
HttpURLConnection conn=(HttpURLConnection)url.openConnection();
InputStreamReader inReader = new InputStreamReader(conn.getInputStream());
BufferedReader br = new BufferedReader(inReader);
StringBuffer sb = new StringBuffer();
String line;
while((line = br.readLine()) != null)
{
sb.append(line);
sb.append("\n");
}
return sb.toString();
}
static public void main(String[] args)
{
try
{
Properties systemProperties = System.getProperties();
systemProperties.setProperty("http.proxyHost","192.168.0.50");
systemProperties.setProperty("http.proxyPort","808");
String content=ServiceProxy.request(new URL("http://www.csdn.net"));
System.out.println("content="+content);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
kjeny2002 2003-09-15
  • 打赏
  • 举报
回复
简单方法

在HTML页面里包含:

<iframe name='mainWindow' width=100% height=100% scrolling=auto frameborder=0 src='abc.com?a=1&b=2'></iframe>

如果在不可见..则把widtht 和height置为0
passren 2003-09-15
  • 打赏
  • 举报
回复

passren 2003-09-15
  • 打赏
  • 举报
回复
webuilder(神军) & Yssss1980(浪子雪影)
谢谢,正是我要的东西,但现在有个问题就是,用这种方式去call 一个远程的delete files的jsp文件,它返回一直是false,jsp文件肯定没问题,我感觉是java会对这样的操作做限制,因为存在安全问题,不知道是不是?
icecloud 2003-09-15
  • 打赏
  • 举报
回复
浏览的提交数据实现原理:SOCKETL连结到目标服务器的80口,POST命令发送数据

String host="sohu.com";
int port=80;
fileName="/news/cgi-bin/add.cgi";
String content="可以是name=value形式";
Socket sc = new Socket(host,port);
PrintWriter pw = new PrintWriter(new OutputStreamWriter(sc.getOutputStream()));
String cmd = "POST "+fileNaem+" HTTP/1.0\r\n"+"User-Agent: myselfHttp/1.0\r\n"+
"Accept: www/source; text/html; image/gif; */*\r\n";
cmd += "Content-type: application/x-www-form-urlencoded\r\n";
cmd += "Content-length: " + content.length() + "\r\n\r\n";
cmd += content+"\r\n";
cmd += 要发送的数据;//注意最后要以\r\n结尾
pw.print(cmd);
pw.close();
swinging 2003-09-14
  • 打赏
  • 举报
回复
楼主的想法好奇怪。sweat y
webuilder 2003-09-14
  • 打赏
  • 举报
回复
<%@page import="java.io.*,java.net.*"%>

URL url = new URL(yoururl);
URLConnection conn = url.openConnection();
OutputStream out = conn.getOutputStream();
//向目标页面传递数据
//out.write(...);
out.close();
InputStream in = conn.getInputStream();
//获得目标页面返回的信息
//in.read(...);
in.close();

Diego2000 2003-09-14
  • 打赏
  • 举报
回复
关注中。。。
timtin0361 2003-09-14
  • 打赏
  • 举报
回复
sendRedirect(url?id=12&&type="top"&&其他参数)
passren 2003-09-14
  • 打赏
  • 举报
回复
大虾说清楚一点啊!
zwxu 2003-09-14
  • 打赏
  • 举报
回复
用response传递
passren 2003-09-14
  • 打赏
  • 举报
回复
对我就想用第三种方法,其实也不是后台操作,是不想用sendRedirect来在两个页面跳,想直接通过URL url = new URL ("http://....") , url.openConnection() ..
这种方法来实现传递参数给远程的jsp页面,然后能返回执行成功的标志。

哪位大虾给个idea!谢谢
dmhorse 2003-09-14
  • 打赏
  • 举报
回复
1.hidden frame,iframe
2.javascript support load page at backupground
3.use URL class get remote url

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧