Need help about jsp form beans

Sthokala
Sthokala used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
use

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

Author

Commented:
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 ...
Announcing the Winners!

The results are in for the 15th Annual Expert Awards! Congratulations to the winners, and thank you to everyone who participated in the nominations. We are so grateful for the valuable contributions experts make on a daily basis. Click to read more about this year’s recipients!

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();

Author

Commented:
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
var strURL = "loginbean.jsp?loginType="+cpoeLogin; thats ok ..

without setting the value in bean you cant get the value so u can use request parameter and set that values to ur bean

Author

Commented:
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

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial