Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
220 views
in Technique[技术] by (71.8m points)

java - Parameters cannot be resolved in servlets

I am tryin to get the credentials from jsp page-index.jsp In my servlet-LoginServletwhen under package dao i use

String userName = request.getParameter(usrnm_gtalk);
String password = request.getParameter(password_gtalk);

it says usrnm_gtalk and password_gtalk cannot be resolved.

in my jsp

<form name="LoginForm" method="post" action="/dao/LoginServlet>   
<input type="text" name="usrnm_gtalk"/>
<input type="password" name="password_gtalk" />

web.xml

<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <description></description>
    <display-name>LoginServlet</display-name>
    <servlet-name>LoginServlet</servlet-name>
    <servlet-class>dao.LoginServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>LoginServlet</servlet-name>
    <url-pattern>/Login</url-pattern>
  </servlet-mapping>

i have the servlet-api jar in the lib as well as build path

can anyone point out wat is the problem Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You need to represent them as strings, with doublequotes, not as non-existing variables (as the compiler is trying to tell you).

String userName = request.getParameter("usrnm_gtalk"); 
String password = request.getParameter("password_gtalk");

See also:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...