这个问题怎么用jsp+servlet来做?急

kulama2004 2003-08-12 10:22:31
index.jsp有一个text输入框和一个按钮
随便输入字符串,按下按钮
index.jsp把字符传参数传给servlet
servlet负责把收到参数输出
谢谢
急~
最好把可用代码贴出

...全文
21 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
kulama2004 2003-08-12
  • 打赏
  • 举报
回复
ding
kulama2004 2003-08-12
  • 打赏
  • 举报
回复
index.jsp的内容呢?
Leemaasn 2003-08-12
  • 打赏
  • 举报
回复
楼上的都搞定了。
ejbcreate 2003-08-12
  • 打赏
  • 举报
回复
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class Test extends HttpServlet
{
public void init(ServletConfig rScfg) throws ServletException
{
super.init(rScfg);
}

public void doGet(HttpServletRequest rRequest, HttpServletResponse rResponse) throws ServletException, IOException
{
String lRtnStr = "";
PrintWriter lPW = null;

rResponse.setContentType("text/html; charset=gb2312");
rResponse.setHeader("Pragma", "no-cache");
lPW = rResponse.getWriter();

try
{
lRtnStr = rRequest.getParameter("yourTextName");
lPW.print(lRtnStr);
}
catch(Exception ex)
{
System.out.println("ViewReportModel.java Excpt: "+ex.toString());
ex.printStackTrace(System.out);

}
}

public void doPost(HttpServletRequest rRequest, HttpServletResponse rResponse) throws ServletException, IOException
{
doGet(rRequest, rResponse);
}

public void destroy()
{
super.destroy();
}
}
zyp80 2003-08-12
  • 打赏
  • 举报
回复
强烈建议你现找本书从头学学,这样问是什么也问不出来的,找本jsp的书
overloadma 2003-08-12
  • 打赏
  • 举报
回复
怎么把servlet嵌入到jsp中呢?是不是在<form action="YourServlet">?
servlet又要保存在那里?

81,092

社区成员

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

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