当前位置: 技术问答>java相关
菜鸟提问,关于SERVLET的!
来源: 互联网 发布时间:2017-03-28
本文导语: 登陆页面填入后发送至如下的SERVLET文件: 问题用/* …… */标注出来了: import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.*; public class LoginServlet extends HttpServlet { static final private String ...
登陆页面填入后发送至如下的SERVLET文件:
问题用/* …… */标注出来了:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class LoginServlet extends HttpServlet {
static final private String CONTENT_TYPE = "text/html; charset=GBK";
//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();
/* if(name=="Admin")
{
out.println("");
out.println("Servlet1");
out.println("");
out.println("
out.println("");
//getServletContext().getResource("ourwebsite.admIndex").forward(request,response);
}
else
{
}*/
提问:登陆页面我输入用户名为:Admin 可输出页面为空,为什么?
}
//Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request,response);
}
//Clean up resources
public void destroy() {
}
}
问题用/* …… */标注出来了:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class LoginServlet extends HttpServlet {
static final private String CONTENT_TYPE = "text/html; charset=GBK";
//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();
/* if(name=="Admin")
{
out.println("");
out.println("Servlet1");
out.println("");
out.println("
Success!"+"Success!"+"
");out.println("");
//getServletContext().getResource("ourwebsite.admIndex").forward(request,response);
}
else
{
}*/
提问:登陆页面我输入用户名为:Admin 可输出页面为空,为什么?
}
//Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request,response);
}
//Clean up resources
public void destroy() {
}
}
|
name=="Admin"===>name.equals("Admin")
|
if(name.equals("Admin"))
{
out.println("");
out.println("Servlet1");
out.println("");
out.println("
out.println("");
//getServletContext().getResource("ourwebsite.admIndex").forward(request,response);
}
else
{
}
另外把 dopost 加上,and good luck!
{
out.println("");
out.println("Servlet1");
out.println("");
out.println("
Success!"+"Success!"+"
");out.println("");
//getServletContext().getResource("ourwebsite.admIndex").forward(request,response);
}
else
{
}
另外把 dopost 加上,and good luck!