开发者

Parameters cannot be resolved in servlets

开发者 https://www.devze.com 2023-02-21 11:16 出处:网络
I am tryin to get the credentials from jsp page-index.jsp In my servlet-LoginServletwhen under package dao i use

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>
开发者_JAVA技巧

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

can anyone point out wat is the problem Thanks


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:

  • The Java Tutorials - Strings
  • Servlets info page - contains a little hello world
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号