Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

static results in JSP pages

 
natarajan raman
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,
I am a new member of the group.I have to build an application using JSP.
I created the .JSP files and put them in the tomcat directory jsp-examples\mydirectory\..
also i created my login.java file and put that at WEB-INF\classes directory.
Now the problem is when i called the TOMCAT i cud execute and link my JSP files with the
class java file.The deatils which i get for the 1st time remains for ever without getting
refreshed.even incase i change the contents of the .java file it doesn't change at all.
how to rectify it.please help.i have given the code for ur reference.

the codes are as follows

1) login.jsp

<html>
<body>
<FORM name="login" METHOD="POST" ACTION="Welcome.jsp">
Username:<INPUT name="id" type="text">
Password: <input name ="pwd" type="password">
</form>
</html>

2) Welcome.jsp

<%@ pageimport ="pj05t05.nata.*"%> //this is my package name
<html>
<head>
<meta http-equiv ="20" />
<body>
<%
String id=request.getParameter("id");
String pwd=request.getParameter("pwd");
login l1=new login();
String name= l1.validate(id,pwd);
%>

<%=name%>
</body>
</head>
</html>

3) login.java

package pj05t05.nata;
public class login
{
public String validate(String id,String pwd)
{

String s1,s2;
s1="t05";s2="t05";
if( s1.equals("id") & s2.equals("pwd"))
return "nata";
else
return "here";
}
}


this is my probs as i need to know the fix it ASAP please help me out.
Thanking you in advance,
nata.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure if this is the problem you are talking about, but the login.validate() method is wrong - the existing code will *always* return the String "here" because it tests the String "t05" against the String "id" - *NOT* the value held in the String variable id - the actual String literal "id". The same problem exists with pwd. Leave the quotes off both id and pwd in the equals statements.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65535
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It also sounds like you may be expecting your .java files to automatically get recompiled when you change them. If this impression is correct, be advised that you must compile changes to your java files and be sure that their class files end up in the right place.

Also, natarajan, JavaRanch is a community of people from all over the world, many of who are not native English speakers. While using abbreviations like "u" instead of spelling out "you" is convenient when text messaging your friends on a cell phone or in a chat room, it presents an extra challenge to those that are already struggling with English. Additionally, such shortcuts may confound automated translation tools that patrons of the Ranch may be making use of.

I would like to ask for your help in making the content of JavaRanch a little easier to read for everybody that visits here by not using such abbreviations.

thanks,
bear
JSP Forum Bartender
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!