<html>
<head>
<title>HR WorkWays</title>
<SCRIPT LANGUAGE="JavaScript">
if(window.history.forward(1) != null) window.history.forward(1);
</script>
<script language="JavaScript" src="/theme/disabledRightclick.js""></script>
<SCRIPT LANGUAGE=JavaScript FOR=window EVENT=onbeforeunload>
if (window.event.clientY < 0 && window.event.clientY < -80) {
valuex=window.event.returnValue = "";
}
</script>
</head>
<body>
</body>
</html>
<!-- Added for GSFIX -->
<div style="font: bold 12px Arial; color:#FF0000"></div>
<html>
<head>
<title>PAN NO</title>
<style type="text/css">
div#rolltipDiv {
position:absolute; visibility:hidden;
left:0; top:0; z-index:1000;
font:Arial, Helvetica, sans-serif;
width:220px; padding:3px; font-size:11px;
background-color:#dee7f7; border:1px solid #336;
}
.aceTextField {
border-width: 1;
border-style: single;
font-size: 2.5 mm;
font:Arial, Helvetica, sans-serif;
font-weight :normal;
text-align : right;
}
.aceNoTextField {
border-width: 0;
border-style: single;
font-size: 2.5 mm;
font:Arial, Helvetica, sans-serif;
font-weight :normal;
text-align : right;
}
.buttStyle {
background-color: #EEEEEE;
border-width: 1;
border-color: #DDDDDD;
font-size: 7pt;
font:Arial, Helvetica, sans-serif;
font-weight: bold;
}
</style>
<style type="text/css">
<!--
.style10 { font:Arial, Helvetica, sans-serif; font-size: 12px; color: #000000; font-weight: bold; }
.style15 { font:Arial, Helvetica, sans-serif; font-size: 12px; color: #0000ff; font-weight: bold; }
.style20 { font:Arial, Helvetica, sans-serif; font-size: 9px; color: 2; }
a {
font-family: tahoma;
font-size: xx-small;
}
.style42 {color: #FFFFFF; font:Arial, Helvetica, sans-serif;}
.style58 { font:Arial, Helvetica, sans-serif; font-size: 9px; color: #FFFFFF; font-weight: bold; }
.style65 {color: #000000 font:Arial, Helvetica, sans-serif;}
body {
}
a:link {
text-decoration: none;
color: #000000;
}
a:visited {
text-decoration: none;
color: #000000;
}
a:hover {
text-decoration: none;
color: #000000;
}
a:active {
text-decoration: none;
color: #000000;
}
body,td,th {
color: #000000;
}
.style79 {color: #666666 font:Arial, Helvetica, sans-serif;}
.style86 {font-size: 14px;
font-weight: bold;
font:Arial, Helvetica, sans-serif;
}
.style87 {font-size: 14px; color: #000000; }
.style88 {font-size: 14; }
.heading
{
border-width:0;
border-color:#185081;
text-align:left;
font-size: 8pt;
font-weight: bold;
font:Arial, Helvetica, sans-serif;
foreground-color:#ffffff;
}
.msgStl
{
border-width:0;
border-color:#185081;
text-align:center;
font-size: 8pt;
font-weight: bold;
font:Arial, Helvetica, sans-serif;
foreground-color:#ffffff;
}
-->
</style>
<SCRIPT language="javascript">
// VJK: Later we can remove
if(window.parent.contents == null) {
window.showModalDialog('/New_Window_error.html','window','title:Error ; dialogWidth:400px;dialogHeight:310px; status:no');
if(navigator.appName == 'Netscape'){
window.stop();
} else {
document.execCommand('stop');
}
}
// VJK: Later we can remove
function doValidate()
{
myFrm = document.forms.panNo;
var str_pan = allTrim(myFrm.pan_no.value);
if(validate_pan(str_pan) == false)
{
return false;
}
if(myFrm.pan_no.value == 'APPPP1234W')
{
alert('Please enter a new PAN value.');
return false;
}
document.forms.panNo.flag.value='P';
**document.getElementById("cuen").value="hc|aa|faaf|offaa||faa{a||f^aaaafafafaff||afa|fafff|a}o^f#}c^";**
document.getElementById("url").value="/pan.jsp";
document.forms.panNo.action="/pan.jsp";
document.forms.panNo.submit();
}
function allTrim(string)
{
var temp = "";
string = '' + string;
splitstring = string.split(" ");
for(i = 0; i < splitstring.length; i++)
{
temp += splitstring[i];
}
return temp;
}
function validate_pan(str_pan1)
{
var str_pan = allTrim(str_pan1);
//var str_pan = str_pan1;
if (str_pan.length == 0)
{
alert("Pan Number cannot be blank.");
document.getElementById("pan_no").focus();
return false;
}
if(str_pan.length!=0 && str_pan!="APPLIEDFOR" && str_pan!="PANAPPLIED" && str_pan!="PANINVALID" && str_pan!="PANNOTAVBL")
{
var reg= new RegExp("[A-Z][A-Z][A-Z][A-Z][A-Z][0-9][0-9][0-9][0-9][A-Z]");
if(reg.test(str_pan)==false)
{
alert("The first 5 characters of Pan No should be alpha in caps, the next 4 should be numerals and the last charater an alphabet in caps OR it should be APPLIEDFOR in capital letters.");
document.getElementById("pan_no").focus();
return false;
}
if(str_pan.charAt(3)!='P')
{
alert("The fourth character of the PAN Number should be aplhabet P ");
return false;
}
}
}
function resizePan(obj)
{
if(obj.value == 'PAN NOT AVAILABLE / PAN APPLIED')
{
obj.size = '12';
obj.maxLength = '10';
}
document.getElementById('pan_no').value = "";
}
</script>
<style type='text/css'> body { scrollbar-face-color:ghostwhite; scrollbar-highlight-color:darkgray; scrollbar-3dlight-color:lightblue; scrollbar-darkshadow-color:gray; scrollbar-shadow-color:darkslateblue; scrollbar-arrow-color:midnightblue; scrollbar-track-color:gainsboro; } </style>
<link href="/theme/Styles_Modified.css" rel="stylesheet" type="text/css" />
</head>
<body >
<form name="panNo" method="post" action="/pan.jsp">
<INPUT TYPE="hidden" NAME="cuen" id="cuen" VALUE="">
<INPUT TYPE="hidden" NAME="url" id="url" VALUE="">
<center>
<div align="center"></div>
<table width="43%" border="0" align="center">
<tr>
<td height="168" colspan="3">
<table bgcolor="#F2F3F4" width="418" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" rules="none">
<tr bgcolor="#185081" >
<td colspan="2"><div align="center" class="tableHeader13">Update PAN </div></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td width="143" class="tableContent11b"><p> Employee ID</p></td>
<td width="269" class="tableContent11"><p align="left">21865275</p></td>
</tr>
<tr>
<td width="143" height="24" class="tableContent11b"><p> Employee Name</p></td>
<td width="269" class="tableContent11"><p align="left">ABC21865275</p></td>
</tr>
<!--
<tr bgcolor="#FFFFFF" class="style58">
<td width="143" height="24"><p class="style87"> Existing PAN</p></td>
<td width="269"><p align="left" class="style88">AGOPR99999</p></td>
</tr>
-->
<tr>
<td height="26" class="tableContent11b"><span> PAN</span></td>
<td width="269" class="tableContent11"><input name="pan_no" id="pan_no" type="text" size='12' maxlength='10' value="APPPP1234W" onFocus="resizePan(this)" class="textBoxEntryNo11L" >
</td>
</tr>
</table>
</td>
</tr>
</table>
<table align="center">
<tr>
<td>
<input type="button" name="Submit" value="Confirm PAN" onClick="doValidate()" class="buttonStyle12">
</td>
</tr>
</table>
</center>
<table align="center" width="434">
<tr>
<td width="434" height="10"></td>
</tr>
<tr>
<td height="40">
<div class="messageBlue11b">This screen is enabled from
01/05/2014
to 15/11/2014
</div>
</td>
</table>
<INPUT TYPE='hidden' NAME='jspName' VALUE='pan'>
<input type="Hidden" name="flag" VALUE="">
</form>
</body>
</html>
[1]: http://i.stack.imgur.com/SS7BO.jpg
For the following response code during get request,i need to extract the value document.getElementById("cuen").value="#aaoacaaaaafaaaaaaaa}ck#|o##cfff##k^c#c{a^{ko{{}|{f{c{c{o}{{"; and this need to post to next HTTP request. I used following parameters
![Regular Expression Extractor in Jmeter][10]
please elaborate to extract the regex
Try this,
document.getElementById\(\"cuen\"\)\.value=\"(.*)\";
you need to escape special characters.
I have tried it, working on my machine.
Try bypass marks . ( ) " before value="(.+?)" by mark /
Like: document\ .getElementById\ (\"cuen\"\ )\ .value="(.+?)" <- try without spacebar's
Use below mentioned Regular expression:
.document\.getElementById\(\"cuen\"\)\.value="(.+?)".
Also keep Match No. as "1"
Hope this will help.
Related
I am having trouble authenticating with HTMLUnit on a webpage. I enter a username and password, and then click sign in, then check the title of the page, and it is still the sign in page. SO I am not signed in properly.
What is going wrong here? I'm trying to use Fiddler and Charles for debugging but I don't see my requests show up there. Does this Java code make sense for authentication with the given website? Any debugging tips?
Please help me! Thank you.
My code:
package com.company;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.*;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.jupiter.api.*;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.CookieManager;
public class Main {
static WebClient webClient;
static CookieManager cookieManager;
static String username = "MyUsername";
static String password = "MyPassword";
#Before
public static void init() throws Exception {
webClient = new WebClient();
cookieManager = new CookieManager();
cookieManager = webClient.getCookieManager();
cookieManager.setCookiesEnabled(true);
webClient.getOptions().setTimeout(90000);
webClient.setJavaScriptTimeout(90000);
}
#After
public static void close() throws Exception {
webClient.close();
cookieManager.clearCookies();
}
public static void signIn() throws Exception {
//Acquire location for URI, password, username, submitbutton
HtmlPage page1 = webClient.getPage("https://h3c.mlspin.com/signin.asp#ath");
HtmlForm form = page1.getFormByName("loginform");
HtmlTextInput uName = form.getInputByName("user_name");
HtmlPasswordInput passWord = form.getInputByName("pass");
HtmlButton button = form.getFirstByXPath("//*[#id=\"loginForm\"]/table/tbody/tr[7]/td/button");
uName.setValueAttribute(username);
passWord.setValueAttribute(password);
HtmlPage page2 = button.click();
System.out.println("HTMLUNIT UserText : \n" + uName.getText());
System.out.println("HTMLUNIT PassText : \n" + passWord.getText());
System.out.println("Results p2 " + page2.getTitleText());
System.out.println("Results p2 " + page2.getPage());
}
#Test
public static void givenAClient_gatherInfo() throws Exception {
webClient.getOptions().setJavaScriptEnabled(true);
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.getOptions().setCssEnabled(false);
webClient.getOptions().setRedirectEnabled(true);
webClient.getCache().setMaxSize(0);
}
public static void main(String[] args) throws Exception {
init();
givenAClient_gatherInfo();
signIn();
close();
}
}
<!-- Latest compiled and minified CSS -->
<LINK href="/css/Signin.css" type=text/css rel=stylesheet>
<script language='javascript'>
window.sessionStorage.clear();
</script>
<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,
shrink-to-fit=no">
<meta http-equiv="CACHE-CONTROL" content="NO-CACHE">
<meta http-equiv="expires" content="0">
<title>pinergy - Sign In</title>
<link href="/style.asp" type="text/css" rel="stylesheet">
<script type="text/javascript" src="/shared/scripts/3rdParty/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="/shared/scripts/3rdParty/bootstrap-4.1.1/bootstrap.min.js"></script>
<script type="text/javascript" src="/shared/scripts/cookieConsent.js?v=2"></script>
<script language="JavaScript">
var ath;
ath = {}
;
var isMobile = function() {
return /(iphone|ipod|(android.*mobile)|blackberry|windows ce|palm|symbian|nexus 7|xoom|windows phone)/i.test(navigator.userAgent);
}
;
var isIPad = function() {
return /(ipad)/i.test(navigator.userAgent);
}
function CheckSavePassword() {
if (document.loginform.SavePassword.checked) {
document.loginform.SavePassword.checked = false;
} else {
document.loginform.SavePassword.checked = true;
}
}
function parseQueryString(queryString) {
var QueryString = {};
queryString = queryString.slice(queryString.indexOf("?") + 1);
var qsArray = queryString.split("&");
for (var i = 0; i < qsArray.length; i++) {
var arr = qsArray[i].split("=");
QueryString[arr[0]] = arr[1];
}
return QueryString;
}
if (window != top) {
top.location.href = location.href;
}
</script>
<style>
body {
padding: 0;
}
INPUT.login {
height: 22px;
border: 1px solid #808080;
padding: 2px 4px;
background-image: url('images/bg_input.gif');
}
.mobile {
padding: 6px;
align-content: center;
align-self: center;
width: 90%;
height: auto;
display: none;
text-align: center;
border: 4px solid #E7E7E7;
border-radius: 15px;
color: #444;
margin: auto;
background: -moz-linear-gradient(top, #FFFFFF, #E7E7E7);
background: -ms-linear-gradient(#FFFFFF, #E7E7E7);
background: -webkit-gradient(linear, left top, left bottom, from(#FFFFFF), to(#E7E7E7));
max-width: 25rem;
}
.mobileButton {
font-weight: bold;
border-top: 1px outset grey;
border-left: 1px outset grey;
-moz-border-radius: 10px 10px 10px 10px;
-webkit-border-radius: 10px 10px 10px 10px;
border-radius: 10px 10px 10px 10px;
-webkit-appearance: none;
-moz-appearance: none;
min-height: 2rem;
/*width:90px;
height:54px;
font-family:Arial;
font-size:x-large;*/
}
.yes {
background-color: #FBAF41;
}
.no {
background-color: #BEBEBE;
}
.mobileCheckTable {
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, sans-serif !important;
}
.mobileCheckTable td {
vertical-align: top;
}
.textContent {
font-size: .9rem;
text-align: center;
font-weight: 500;
}
.textContent1Child {
white-space: nowrap;
padding-left: .5rem;
}
.mobilecheck {
height: 1.2rem;
width: 1.2rem;
vertical-align: top;
padding: 0;
border: 1px solid rgba(0, 0, 0, 0.3);
}
.mobilequest {
margin: 0 auto;
max-width: 20rem;
box-sizing: border-box;
float: left;
padding-left: .5rem;
padding-bottom: .5rem;
}
div#remember {
font-size: 0.88rem;
}
.mls-bootstrap-font {
font-size: 1rem;
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, sans-serif;
}
.sm-remember {
display: none;
}
#media only screen and (min-width: 476px) {
.mobile {
padding: 15px;
}
.sm-remember {
display: initial;
}
.mobilequest {
padding-bottom: 1rem;
}
.mobilequest,
.textContent1Child {
padding-left: 1rem;
}
}
#media only screen and (min-width: 768px) {
.mobilequest.textContent {
font-size: 1.5rem !important;
}
.textContent1Child {
font-size: 1.2rem !important;
}
}
#media only screen and (min-width: 1024px) {
.mobilequest.textContent {
font-size: 1.6rem !important;
}
.textContent1Child {
font-size: 1.2rem !important;
}
}
</style>
<link rel="icon" href="images/apple-touch-icon-120x120.png" type="image/x-icon" />
<link rel="shortcut icon" href="images/apple-touch-icon-120x120.png" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="css/addtohomescreen.css">
<script src="Scripts/addtohomescreen.js"></script>
<link rel="apple-touch-icon-precomposed" href="images/apple-touch-icon-120x120.png" type="image/x-
icon" sizes="120x120" />
<link rel="apple-touch-icon-precomposed" href="images/apple-touch-icon-152x152.png" type="image/x-
icon" sizes="152x152" />
<link rel="shortcut icon" href="images/apple-touch-icon-152x152.png" type="image/x-icon" sizes="152x152" />
<link rel="apple-touch-icon-precomposed" href="images/apple-touch-icon-57x57.png" type="image/x-
icon" sizes="57x57" />
</head>
<body marginheight="0" marginwidth="0" topmargin="0" leftmargin="0">
<table height="100%" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="100%" height="100%">
<form name="loginform" id="loginForm" method="POST" action="signin.asp" style="margin:
0px" onsubmit="return signInFn.loginFormOnSubmit();
">
<input name="cxzvvfbvvalideguaueff" value="DT: 8/16/2020 8:18:40 PM" type="hidden"><input name="Page_Loaded" value="DT: 8/16/2020 9:25:16 PM" type="hidden">
<table border="0" cellspacing="0" cellpadding="0" class="mls-login">
<tr>
<td><img src="images/MLSPIN_Logo.jpg" width="240" height="60" /></td>
</tr>
<tr>
<td class="text-left pl-4"><span class="h4">Sign In to</span><img src="images/pinergy-logo.jpg" width="90" height="30" /></td>
</tr>
<tr>
<td class="pl-2"><input class="form-control" type="text" style="width: 220px;" name="user_name" maxlength="8" value="MyUsername" placeholder="Enter Your Agent ID"></td>
</tr>
<tr>
<td class="pl-2"><input class="form-control" type="password" style="width: 220px" name="pass" maxlength="20" placeholder="Password"></td>
</tr>
<tr>
<td class="text-left pl-2">Forgot your password?</td>
</tr>
<tr>
<td class="text-left pl-2 mls-login-rem-me"><input type="checkbox" name="SavePassword" value="Y"><span onclick="CheckSavePassword();">Remember My Password</span></td>
</tr>
<tr>
<td><button class="btn btn-sm btn-primary" type="submit">Sign In</button>
<!--<input class="btn btn-sm btn-primary" type="submit" value="Sign In" name="signin"></td>--></tr>
</table>
</form>
</td>
</tr>
<tr>
<td>
<footer class="mls-site-footer">
<div class="footer-content">
<div class="footer-icon MLSPINlogo mr-1"></div>
<div class="mb-1">©
<span>MLS Property Information Network,
Inc.</span></div>
<div class="vert-bar">|</div>
<div>900 Hartford Turnpike, fakeville, TN 01245 </div>
<div class="vert-bar">|</div>
<div>800-700-3189 </div>
<div class="vert-bar">|</div>
<div class="footer-content-group">
<div class="d-inline">Access Notice</div>
<div class="vert-bar d-inline">|</div>
<div class="d-inline">Privacy Policy</div>
<div class="vert-bar d-inline">|</div>
<div class="d-inline">Copyright Policy</div>
</div>
<div class="vert-bar">|</div>
<div class="footer-user-count">2190 users online right now!</div>
</div>
</footer>
</td>
</tr>
</table>
<div id="cookieConsentBootstrapModal" class="modal mls-bootstrap-font" role="dialog" aria-labelledby="cookieConsentTitle" aria-describedby="cookieConsentDesc" aria-hidden="true" data-backdrop="static" tabindex="-1">
<div class="modal-dialog" role="document">
<!-- Modal content-->
<div class="modal-content mls-modal-bgcolor">
<div class="modal-header">
<h1 class="modal-title h5" id="cookieConsentTitle">This website uses cookies</h1>
</div>
<div class="modal-body" id="cookieConsentDesc">This website uses cookies for a number of purposes, including to enhance your browsing experience. Learn more about our use of cookies in our Privacy Policy. </div>
<div class="modal-footer"><button type="button" class="btn btn-sm btn-primary mls-js-cookie-consent-action" data-dismiss="modal">OK</button></div>
</div>
</div>
</div>
<script language="JavaScript">
document.loginform.user_name.focus();
alert("Incorrect password!\nPlease try again.");
</script>
<script>
if (!window.location.hash.match('ath')) {
addToHome = addToHomescreen({
detectHomescreen: true,
autostart: false,
icon: true,
lifespan: 15,
maxDisplayCount: 1,
appID: 'com.mlspin.MobileWeb'
});
addToHome.show();
window.location.hash = '#ath';
}
</script>
<script type="text/javascript">
var signInFn = (function() {
var _suppressCookieConsent = false;
function _loginFormOnSubmit() {
var isValid = true;
if (!_suppressCookieConsent && !cookieConsentUtil.cookieConsentExists()) {
isValid = false;
cookieConsentUtil.showCookieBanner();
}
_enableDisableLoginForm();
return isValid;
}
function _enableDisableLoginForm() {
if (!_suppressCookieConsent && !cookieConsentUtil.cookieConsentExists()) {
document.getElementById("loginForm").action = "signin.asp";
} else {
document.getElementById("loginForm").action = "validate_new.asp";
}
}
function _focusOnFirstElement() {
try {
var focusable = $('button:visible, a[href]:visible, input:visible, select:visible, textarea:visible, [tabindex]:visible:not([tabindex="-1"])');
if (focusable.length > 0) {
var firstFocusable = focusable[0];
firstFocusable.focus();
}
} catch (ex) {}
}
function _docOnReady() {
//_focusOnFirstElement();
cookieConsentUtil.init({
onStoreCookieConsent: function() {
_enableDisableLoginForm();
setTimeout(_focusOnFirstElement, 0);
}
});
cookieConsentUtil.docOnReady();
_enableDisableLoginForm();
}
return {
loginFormOnSubmit: _loginFormOnSubmit,
docOnReady: _docOnReady
};
}
());
$(document).ready(function() {
signInFn.docOnReady();
}
);
</script>
</body>
</html>
Looking in the javascripts there's this section:
if (!_suppressCookieConsent && !cookieConsentUtil.cookieConsentExists()) {
document.getElementById("loginForm").action="signin.asp";
}
else{
document.getElementById("loginForm").action="validate_new.asp";
}
Seems from looking at the http requests validate_new.asp is returning a 302 (redirect) to signin.asp. This might help locate the relevant requests.
I tried looking a bit deeper but I'd need to try running your code which I've not got time to do right now. If I find time I'll come back to this as it should be possible.
I have records of products in my mysql database (I'm talking about a spring MVC java project using hibernate).
I have a html (and css) form of a search screen, here is its code:
<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
* {box-sizing: border-box;}
body {
margin: 0;
font-family: Arial, Helvetica, sans-serif;
}
.topnav {
overflow: hidden;
background-color: #e9e9e9;
}
.topnav a {
float: left;
display: block;
color: black;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.topnav a:hover {
background-color: #ddd;
color: black;
}
.topnav a.active {
background-color: #2196F3;
color: white;
}
.topnav .search-container {
float: right;
}
.topnav input[type=text] {
padding: 6px;
margin-top: 8px;
font-size: 17px;
border: none;
}
.topnav .search-container button {
float: right;
padding: 6px 10px;
margin-top: 8px;
margin-right: 16px;
background: #ddd;
font-size: 17px;
border: none;
cursor: pointer;
}
.topnav .search-container button:hover {
background: #ccc;
}
#media screen and (max-width: 600px) {
.topnav .search-container {
float: none;
}
.topnav a, .topnav input[type=text], .topnav .search-container button {
float: none;
display: block;
text-align: left;
width: 100%;
margin: 0;
padding: 14px;
}
.topnav input[type=text] {
border: 1px solid #ccc;
}
}
</style>
</head>
<div class="topnav">
<a class="active" href="#home">Home</a>
About
Contact
<div class="search-container">
<form action="/search1">
<input type="text" placeholder="Search.." name="search">
<button type="submit"><i class="fa fa-search"></i></button>
</form>
</div>
</div>
<div style="padding-left:16px">
</div>
<style>
table {
border-collapse: collapse;
border-spacing: 0;
width: 100%;
border: 1px solid #ddd;
}
th, td {
text-align: left;
padding: 16px;
}
tr:nth-child(even) {
background-color: #f2f2f2
}
</style>
</head>
<body>
<h2>Search Results</h2>
<table>
<tr>
<th>Product ID</th>
<th>Product Name</th>
<th>Product Price</th>
</table>
</body>
</html>
I also have a java function that connect to my database and fetches the correct search results (currently it just prints the results to the console) , here is that function:
#RequestMapping("/results")
public String results(UserSearch search){
Configuration cfg = new Configuration();
cfg.configure("hibernate.cfg.xml");
SessionFactory factory = cfg.buildSessionFactory();
Session session = factory.openSession();
ArrayList<ProductsEntity> li = (ArrayList<ProductsEntity>)session.createQuery("from ProductsEntity").list();
for (ProductsEntity c: li) {
if (c.getProductName().toLowerCase().contains(search.getSearch().toLowerCase())){
System.out.println(c.getProductName());
}
}
session.close();
factory.close();
return "results";
}
What I want to do is to insert those results from the java function into the html form (so that the html will contain a table with the search results), does anyone knows are?
Thanks!
I would say, your form in the HTML page must be a tag <form:form>
and assigned a modelattribute. I believe it will be a ProductsEntity.
The binding of the form tag is explained here.
You will have include the taglib library for tag to work.
Include <%# taglib uri="http://www.springframework.org/tags/form" prefix="form"%> between the <!DOCTYPE html> and the <html> tag.
I am trying to send mails to user who signup through our portal. Everything works fine except that image is not visible in the mail. here is the snippet of code
<html>
<body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" offset="0" bgcolor='#E5E5E5' >
<STYLE>
.headerTop { background-color:#FFCC66; border-top:0px solid #000000; border-bottom:1px solid #FFFFFF; text-align:center; }
.adminText { font-size:10px; color:#996600; line-height:200%; font-family:verdana; text-decoration:none; }
.headerBar { background-color:#FFFFFF; border-top:0px solid #333333; border-bottom:10px solid #FFFFFF; }
.title { font-size:16px; font-weight:bold; color:#295EA0; font-family:arial; line-height:110%; }
.subTitle { font-size:11px; font-weight:normal; color:#666666; font-style:italic; font-family:arial; }
.defaultText { font-size:12px; color:#000000; line-height:150%; font-family:arial; }
.footerRow { background-color:#FFFFCC; border-top:10px solid #FFFFFF; }
.footerText { font-size:10px; color:#996600; line-height:100%; font-family:verdana; }
a { color:#00F; color:#00F; color:#00F; }
</STYLE>
<table width="100%" cellpadding="10" cellspacing="0" class="backgroundTable" bgcolor='#E5E5E5' >
<tr>
<td valign="top" align="center">
<table width="550" cellpadding="0" cellspacing="0">
<tr>
<td style="background-color:#FFFFFF;border-top:0px solid #333333;border-bottom:10px solid #FFFFFF;"><center><IMG id=editableImg1 SRC="#banner#" BORDER="0" title="Reppify" alt="Reppify" align="center"></center></td>
</tr>
I think you need to write the image full path
<tr>
<td style="background-color:#FFFFFF;border-top:0px solid #333333;border-bottom:10px solid #FFFFFF;"><center><IMG id=editableImg1 SRC="**http://www.www.com/banner.jpg**" BORDER="0" title="Reppify" alt="Reppify" align="center"></center></td>
</tr>
I searched high and low and still can't figure this out. I am creating a web to lead form and I have a drop down field called Referral, with choices of Internet, Friend, etc.
If they select Friend, I would like a table row to appear underneath called Friend Name, where they can enter their friend's name. If something else is selected this would be hidden.
Please see the code below. Thank you!
<span style="font-family: arial, helvetica, sans-serif;">Referral: <span class="required" style="color: #ff0000;">*</span></span></td>
<td style="font-size: 12px; font-weight: normal;" width="35%">
<span style="font-family: arial, helvetica, sans-serif;">
<select id="referral_c" name="referral_c" tabindex="1" onchange="show_referral();">
<option selected="selected" value="Internet">Internet</option>
<option value="Friend" id="friend_click">Friend</option>
<tr>
<td style="text-align: left; font-size: 12px; font-weight: normal;" width="15%">
<span style="font-family: arial, helvetica, sans-serif;">Friend Name: <span class="friend" style="color: #ff0000;"></span></span></td>
<td style="font-size: 12px; font-weight: normal;" width="35%">
<span class="friend" style="font-family: arial, helvetica, sans-serif;">
<input id="friend_name_c" type="text" name="friend_name_c" /></span></td>
</tr>
function show_referral(){
var referral = document.getElementById("referral_c");
var referral_text = referral.options[referral.selectedIndex].text;
$("#friend_click").click(function () {
$(".friend").show();
});
}
First, I would be remiss if I didn't recommend putting the styles in a separate css file. Be that as it may, one possible solution is:
<table>
<tr>
<td>
<span style="font-family: arial, helvetica, sans-serif;">Referral: <span class="required" style="color: #ff0000;">*</span></span>
</td>
<td style="font-size: 12px; font-weight: normal;" width="35%">
<span style="font-family: arial, helvetica, sans-serif;">
<select id="referral_c" name="referral_c" tabindex="1" onchange="show_referral();" >
<option selected="selected" value="Internet">Internet</option>
<option value="Friend" id="friend_click">Friend</option>
</select>
</span>
</td>
</tr>
<tr id="friend_row" style="display: none;">
<td style="text-align: left; font-size: 12px; font-weight: normal;" width="15%">
<span class="friend" style="font-family: arial, helvetica, sans-serif;">Friend Name: <span class="friend" style="color: #ff0000;"></span></span>
</td>
<td style="font-size: 12px; font-weight: normal;" width="35%">
<span class="friend" style="font-family: arial, helvetica, sans-serif;">
<input id="friend_name_c" type="text" name="friend_name_c" /></span>
</td>
</tr>
</table>
function show_referral() {
var referral = document.getElementById("referral_c");
var referral_text = referral.options[referral.selectedIndex].text;
if (referral_text === "Friend") {
$("#friend_row").show();
} else {
$("#friend_row").hide();
}
}
UPDATE: complete working page
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
</head>
<body>
<table>
<tr>
<td>
<span style="font-family: arial, helvetica, sans-serif;">Referral: <span class="required" style="color: #ff0000;">*</span></span>
</td>
<td style="font-size: 12px; font-weight: normal;" width="35%">
<span style="font-family: arial, helvetica, sans-serif;">
<select id="referral_c" name="referral_c" tabindex="1" onchange="show_referral();" >
<option selected="selected" value="Internet">Internet</option>
<option value="Friend" id="friend_click">Friend</option>
</select>
</span>
</td>
</tr>
<tr id="friend_row" style="display: none;">
<td style="text-align: left; font-size: 12px; font-weight: normal;" width="15%">
<span class="friend" style="font-family: arial, helvetica, sans-serif;">Friend Name: <span class="friend" style="color: #ff0000;"></span></span>
</td>
<td style="font-size: 12px; font-weight: normal;" width="35%">
<span class="friend" style="font-family: arial, helvetica, sans-serif;">
<input id="friend_name_c" type="text" name="friend_name_c" /></span>
</td>
</tr>
</table>
<script type="text/javascript">
function show_referral() {
var referral = document.getElementById( "referral_c" );
var referral_text = referral.options[referral.selectedIndex].text;
if (referral_text === "Friend") {
$( "#friend_row" ).show();
} else {
$( "#friend_row" ).hide();
}
}
</script>
</body>
</html>
In my jsp page i have following code snippet. This page is coming recursive way during my flow. I am getting a duplicate bean id error while execution of the jsp in the middle of the flow. Can you anyone help me how to check whether bean id already exist or not for the following code?
The full code has been given
code.jsp
<%# page language="java" %>
<%# page import="com.ubsw.risk.AUT_Authenticator.*" %>
<%
String path= System.getProperty("dev_property_path");
System.out.println("dev_property_path----->"+path);
%>
<jsp:useBean id="orbinfra" scope="session" class="com.ubsw.risk.Creation.web.OrbinfraBean" >
<jsp:setProperty name="orbinfra" property="propertiesFile" value="<%=path%>"/>
<%
System.out.println("B4 init of Orbinfra");
try {
orbinfra.init();
System.out.println("after init of Orbinfra");
} catch( Exception ex ) {
System.out.println("error in Orbinfra"+ex);
ex.printStackTrace();
%>
<html>
Caught exception while creating orbinfra <%= ex %>
</html>
<%
}
%>
</jsp:useBean>
<jsp:useBean id="security" scope="session" class="com.ubsw.risk.Creation.web.AuthenticatorBean" >
</jsp:useBean>
<%
boolean showLogin;
showLogin = true;
boolean additionalMessage = false;
String message = "Warning - Users login has expired";
boolean hasAdminRights = false;
// is there a command being sent
String checkcommand = request.getParameter("command");
// does user want to login
if( checkcommand != null ) {
if( checkcommand.equals("login") ) {
try {
String authenticatorModuleLookupValue= System.getProperty("authenticatorModuleLookupValue");
String cookieNamevalue= System.getProperty("cookieNamevalue");
System.out.println(request.getParameter("User_Name"));
System.out.println(request.getRemoteAddr());
System.out.println(request.getLocalAddr());
System.out.println("hello P");
//HttpSession session1 = request.getSession(true);
System.out.println(authenticatorModuleLookupValue+":"+cookieNamevalue);
security.setloginInfo(authenticatorModuleLookupValue,cookieNamevalue);
security.logon(request.getParameter("User_Name"), request.getParameter("Password"), request.getRemoteAddr(), response );
System.out.println("what happened?");System.out.println(security);
showLogin = false;
} catch( LogonFailure le ) {
additionalMessage = true;
message = "Logon failed : " + le.reason;
} catch( Exception ex ) {
additionalMessage = true;
message = "Failed, caught an exception : " + ex;
}
}
}
if( showLogin ) {
try {
showLogin = !security.hasPermission( request );
if( ! showLogin ) {
hasAdminRights = security.hasAdminPermission( request );
}
} catch( TicketIsExpired te ) {
additionalMessage = true;
message = "Warning - Users login has expired";
} catch( Exception ex ) {
additionalMessage = true;
message = "Exception - " + ex;
}
}
//System.out.println("showLogin"+showLogin);
// do we need to show login or not
if( showLogin ) {
%>
<html>
<body>
<FORM NAME="loginForm" ACTION="index.jsp" METHOD="post">
<center>
<%
if( additionalMessage ) {
%>
<b> <%= message %> </b><br>
<%
}
//System.out.println("showLogin"+showLogin);
%>
<br>
<br>
<center>
<table cellspacing="0" cellpadding="0" border="2" bordercolor="#60A0A0">
<INPUT TYPE='hidden' NAME='command' VALUE='login'>
<body>
<tr bgcolor="#60A0A0">
<td align="left" height="17"><font face="Verdana" color="white"><span
style="color: white; font-weight: bold; font-variant: normal; font-size: 10pt; text-align: left">
<center>
Creation Web Application
</center>
</span></font></td>
</tr>
<tr bgcolor="#60A0A0">
<td align="left" height="17"><font face="Verdana" color="white"><span
style="color: white; font-weight: bold; font-variant: normal; font-size: 10pt; text-align: left">Please
Login</span></font></td>
</tr>
<tr>
<td align="left" height="166">
<table border="0" height="116" width="460">
<tbody>
<tr>
<td height="16" width="70"></td>
<td height="16" width="87"></td>
<td height="16" width="164"></td>
<td height="16" width="136"></td>
</tr>
<tr>
<td height="25" width="70"></td>
<td height="25" width="87"><span
style="color: black; font-style: normal; font-family: Verdana; font-weight: bold; font-size: 10pt; text-align: center">Username:</span></td>
<td height="25" width="164"><input type="text"
name="User_Name" maxlength="20"
style="height: 25px; font-family: Verdana; width: 153px"></td>
</tr>
<tr>
<td height="1" width="70"></td>
<td height="1" width="87"></td>
<td height="1" width="164"></td>
<td height="1" width="136"></td>
</tr>
<tr>
<td height="25" width="70"></td>
<td height="25" width="87"><span
style="color: black; font-style: normal; font-family: Verdana; font-weight: bold; font-size: 10pt; text-align: center">Password:</span></td>
<td height="25" width="164"><input type="password"
name="Password"
style="height: 25px; font-family: Verdana; width: 153px"
maxlength="25"></td>
<td height="25" width="136"></td>
</tr>
<tr>
<td height="19" width="70"></td>
<td height="19" width="87"></td>
<td height="19" width="164"></td>
<td height="19" width="136"></td>
</tr>
<tr>
<td height="27" width="70"></td>
<td height="27" width="100"></td>
<td height="27" width="136">
<center><input type="submit" name="Login"
value="Login"
style="height: 25px; bottom: auto; right: auto; font-family: Verdana; background-color: #60A0A0; width: 62px; top: auto; left: auto"></center></td>
</tr>
<tr>
<td height="1" width="70"></td>
<td height="1" width="87"></td>
<td height="1" width="164"></td>
<td height="1" width="136"></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</center>
</FORM>
</body>
</html>
<%
return;
}
%>
As you are saying This page is coming recursive way during my flow.
Try changing scope="page" to scope="request"
Or try renaming beanId to "orbinfra1"
<jsp:useBean id="orbinfra1" scope="session" class="com.ubsw.risk.Creation.web.OrbinfraBean" >
<jsp:setProperty name="orbinfra1" property="propertiesFile" value="<%=path%>"/>
</jsp:useBean>