Link to home
Start Free TrialLog in
Avatar of Sthokala
SthokalaFlag for United States of America

asked on

Need help about jsp form beans

Hi,
  I created a login module with the attached code. I created login module using jsp form beans. I am attaching the code. I am calling login.jsp from index.jsp..from login.jsp I am calling loginbean.jsp. From login.jsp I want to open a window from login.jsp. rightnow I am passing loginname and password as request parameters and is showing up on the title bar. How can I avoid that. I don't want to show the login name and password in window title bar.

I am attaching screens and code. Please help me in solving this.

Thank you,
code.zip
Avatar of Sathish David  Kumar N
Sathish David Kumar N
Flag of India image

use

< form method="post" >  then it wont  display in the title bar ..
Avatar of Sthokala

ASKER

Hi Dravidnsr,
  Thank you for you reply. I have that in my code..

<form name="loginform" method="post" action=""  > in login.txt file.  While clicking on submit button I am calling the below method.

function postLogin(){
      
      var adjustHeight = 40;
       var adjustWidth = 15;
     var height = screen.availHeight-adjustHeight;
     var width = screen.availWidth-adjustWidth;        
     var winProps = "height="+height+",width="+width+",left=0,top=0,resizable=yes,scrollbars=yes";        
     var userName = document.getElementById("userName").value;
     var password = document.getElementById("password").value;
     var strURL = "loginbean.jsp?userName=" + userName+"&password="+password+"&loginType="+"cpoeLogin";
       var winPop = window.open(strURL,"_blank",winProps);
       self.close();
      
}

how can I send username and password data to the loginbean,  without showing them in query string.

Please help me in solving this.

Thank you
is that form submit only right ??

then now need to pass username and password in the URL


you can get the value directly using request.getParameter("userName");

in jsp
<input type="text" name="userName">

text filed name and request parameter name should be same ...
can you post your code i am not able to download your zip file
var winPop = window.open(strURL,"_blank",winProps);
       self.close();

why you create open a window ?
document.formname.action="loginbean.jsp?loginType="+cpoeLogin;
document.formname.submit();
Thank you very much for your quick reply. My login page code

<html>
<head>
<title>Login</title>
<LINK href="css/cpoe.css" rel="stylesheet" type="text/css">
</head>
<style>
body {

  background-position: 50% 50%;
  background-repeat: no-repeat;
}

body{
padding-top: 150px;
padding-left: 120px;
}
.td-padding{

padding-left: 70px;
}
html, body {
height: 50%;
}

</style>


<script type="text/javascript" charset="utf-8">
function postLogin(){
      
      var adjustHeight = 40;
       var adjustWidth = 15;
     var height = screen.availHeight-adjustHeight;
     var width = screen.availWidth-adjustWidth;        
     var winProps = "height="+height+",width="+width+",left=0,top=0,resizable=yes,scrollbars=yes";        
     var userName = document.getElementById("userName").value;
     var password = document.getElementById("password").value;
     var strURL = "loginbean.jsp?userName=" + userName+"&password="+password+"&loginType="+"cpoeLogin";
       var winPop = window.open(strURL,"_blank",winProps);
       self.close();
      
}

function submitenter(myfield, e) {
      var keycode;
      if (window.event)
            keycode = window.event.keyCode;
      else if (e)
            keycode = e.which;
      else
            return true;

      if (keycode == 13) {
            postLogin();
            return false;
      } else{
            return true;
      }
}

</script>

<body >
<form name="loginform" method="post" action=""  >
<br><br>

<table >
<tr><td colspan=2></td></tr>
<tr><td colspan=2>&nbsp;</td></tr>
      <tr>
            <td nowrap="nowrap"><b>Login Name</b></td>
            <td><input type="text" name="userName" id="userName" value="" size="24"></td>
      </tr>
      <tr>
            <td nowrap="nowrap"><b>Password</b></td>
            <td><input type="password" name="password" id="password" value=""  size="24" onKeyPress="return submitenter(this,event)" onBlur="return submitenter(this,event)"></td>
      </tr>
      </table>
      <table>
      <tr>
            
            <td><button name="ok" id ="ok"  onClick="postLogin()" > Login</button></td>
            <td><button name="cancel" id ="cancel"  onClick="window.location.reload()" > Cancel</button></td></tr>
      
      <tr><td colspan=2>&nbsp;</td></tr>
</table>
</form>


</body>
</html>


and loginbean code is

<HTML>  
<HEAD><TITLE>DataBase Search</TITLE></HEAD>  
<BODY>

<%@ page language="Java" import="java.sql.*" %>  

<jsp:useBean id="db" scope="request" class="com.sectra.bean.LoginBean" >

<jsp:setProperty name="db" property="userName" value='<%=request.getParameter("userName")%>'/>
<jsp:setProperty name="db" property="password" value='<%=request.getParameter("password")%>'/>
<jsp:setProperty name="db" property="loginType" value='<%=request.getParameter("loginType")%>'/>

  </jsp:useBean>
<jsp:forward page="hello">
<jsp:param name="username" value="<%=db.getUserName()%>" />
<jsp:param name="password" value="<%=db.getPassword()%>" />
<jsp:param name="loginType" value="<%=db.getLoginType()%>" />

</jsp:forward>


</body>
</html>

I want to open a the page in a window after a successful login.

Please let me know how to solve this.

Thank you
ASKER CERTIFIED SOLUTION
Avatar of Sathish David  Kumar N
Sathish David Kumar N
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you for your reply. I tried your approach and I am getting the result. But my problem here is the data is getting displayed in small login window itself.  After successful login, the data displays in the same small window like shown in the image. I want to open a full screen window after successful login.

Please let me know how to do this.
index.PNG
page.PNG
check ur js file or set the width and heg in the open.window