hello!

Can anyone plz tell me how 2 write z following php code into jsp..Thx in advance..

<?php
         $userid = $_POST["txt_login"];
          $password = $_POST["txt_pwd"];
          //Connecting to database
          include("db_connect.php");

          if (($userid=='admin' OR $userid=='ADMIN') && ($password=='admin' OR $password=='ADMIN'))
                 header( 'Location: http://localhost/MyWeb/admin.php?id='.$userid) ;

           else
          {
                   $Rs = mysql_query("SELECT * FROM Users WHERE UserId = '$userid' AND UserPassword = '$password'");

	    if (mysql_fetch_row($Rs))
		header( 'Location: http://localhost/MyWeb/Basket.php?id='.$userid ) ;

	     else//user does not exist
	     {
		mysql_close($con);
		header( 'Location: http://localhost/MyWeb/user_error.php?id='.$userid ) ;
	     }
           }
           
           mysql_close($con);

?>

There're alot of excellent tutorials about how to write jsp. Google it and you'll find, learning jsp when you only know php is a bit harder than going jsp to php. But I'm confident that you'll be able to get a script going. You'll soon notice that the two languages are very much alike.

thx 4 z advice..it's much more encouraging than z 1st one i got..i actually dont know how 2 put z "mysql_fetch_row($Rs)" in jsp

Because you don't.

Read the JDBC Tutorial.

Edit: And don't use scriptlets in the thing in the first place. Put all DB stuff in one, or more, beans.

Then again, with JNI you could, but it wouldn't b worth the effort.

And you got the response you did, because of the question you asked, which was basically "do this for me".

I'll tell you right now though, you would be much better off first learning JSP (and Java) in general (at least the basics), and how to do it right (i.e. in JSP no scriplets) then you are simply diving in by attempting to convert a PSP script to a Java program. JSP, and Java in general, is many times more flexible, and so, in many ways, many times more complicated than PSP. They do not equate 1 to 1, they operate completely differently.

This article has been dead for over six months. Start a new discussion instead.