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>
Related
I have to read some confirmation emails which are developed by tables in HTML.
I'm using GMail API and Java programming language for it.
I'm doing automatization of the registration process so I have to get the link to the confirmation email and click on that confirm button by Selenium test.
In response I'm getting emails with only text, for eg if I send to my mail some random text, I can get that text in response, however, for table kinds of emails I'm getting messages that the body is null.
This is the HTML code of that email.
Image of the email: Image of email
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<title>Test</title>
<meta content="light only" name="color-scheme" />
<meta name="”x-apple-disable-message-reformatting”" />
<style></style>
</head>
<body class="full-width" data-gr-ext-installed="" data-new-gr-c-s-check-loaded="14.997.0" style="max-width: 600px;width: 100%;background: #333333; margin: 0 auto;">
<div class="full-width" style="width: 100%;padding: 1em 0;"><!--[if mso | IE]>
</td></tr></table>
<![endif]--><!--[if mso | IE]>
<table class="full-width" border="0" cellpadding="0" cellspacing="0" width="600" align="center" style="width: 100%;">
<tr style=" width: 100%;">
<td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;">
<![endif]-->
<div class="full-width" style=" width: 100%;margin:0 auto;max-width:600px;background:#333333;">
<table align="center" border="0" cellpadding="0" cellspacing="0" class="full-width" style="font-size:0px;width:100%;background:#1b2940;">
<tbody class="full-width">
<tr class="full-width">
<td class="full-width" style="text-align:center;vertical-align:top;font-size:0px;padding:0px;"><!--[if mso | IE]>
<table class="full-width" border="0" cellpadding="0" cellspacing="0">
<tr class="full-width">
<td class="full-width" style="vertical-align:middle;width:600px;">
<![endif]-->
<div aria-labelledby="mj-column-per-100" class="full-width" style="vertical-align:middle;display:inline-block;font-size:13px;text-align:left;width:100%;">
<table border="0" cellpadding="0" cellspacing="0" class="full-width" style="vertical-align:middle;" width="100%">
<tbody class="full-width">
<tr>
<td align="center" style="word-break:break-word;font-size:0px;padding:0px;">
<table align="center" border="0" cellpadding="0" cellspacing="0" style="border-collapse:collapse;border-spacing:0px;">
<tbody><!--
<tr>--><!-- <td style="width:600px;">--><!-- <a href="https://www.24bettle.com/?utm_source=system-email&utm_medium=Image"--><!-- target="_blank" >--><!-- <img alt="24Bettle Logo"--><!-- src="http://24bettle.com/images/email_images/button-gradient-pic.png"--><!-- style="outline: none; text-decoration: none; clear: both; border: 0px; max-width: 640px; width: 600px; height: 122px; "--><!-- title=""/>--><!-- </a>--><!-- </td>--><!-- </tr>-->
<tr>
<td style="width:650px"><img class="first-banner" src="https://24bettle.com/images/banners/24header-image-2.png" style="outline: none; text-decoration: none; clear: both; border: 0px; max-width: 600px; width: 100%;" /></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="center" style="word-break:break-word;font-size:0px;padding:0px;"> </td>
</tr>
</tbody>
</table>
</div>
<!--[if mso | IE]>
</td></tr></table>
<![endif]--></td>
</tr>
</tbody>
</table>
</div>
<!--[if mso | IE]>
</td></tr></table>
<![endif]--><!--[if mso | IE]>
<table border="0" cellpadding="0" cellspacing="0" width="600" align="center" style="width:600px;">
<tr>
<td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;">
<![endif]-->
<div class="full-width" style=" width: 100%;margin:0 auto;max-width:600px;background:#fff;">
<table border="0" cellpadding="0" cellspacing="0" class="full-width" style="padding: 2em 2em;vertical-align:middle;" width="100%">
<tbody class="full-width">
<tr>
<td align="left" style="word-break:break-word;font-size:0px;padding:0px;">
<div style="cursor:auto;color:#000000;font-family:Verdana, sans-serif;font-size:20px;line-height:20px;">
<p style="font-size: 20px; margin: 0px 0px 15px; color: rgb(76, 76, 76); text-align: center;">Hello {username},</p>
</div>
</td>
</tr>
<tr class="full-width">
<td align="left" style="word-break:break-word;font-size:0px;padding:0px;">
<div style="cursor:auto;color:#000000;font-family:Verdana, sans-serif;font-size:14px;line-height:20px;">
<table border="0" cellpadding="0" cellspacing="0" style="font-size: 13px; background-color: rgb(255, 255, 255); vertical-align: middle;" width="100%">
<tbody>
<tr>
<td align="left" style="word-break: break-word; font-size: 0px; padding: 0px;">
<div style="cursor: auto; font-family: Verdana, sans-serif; font-size: 14px; line-height: 20px;">
<table border="0" cellpadding="0" cellspacing="0" style="font-family: Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); vertical-align: middle;" width="100%">
<tbody>
<tr>
<td align="left" style="word-break: break-word; font-size: 0px; padding: 0px;">
<div style="cursor: auto; font-size: 14px; line-height: 20px;">
<p><span style="font-family: verdana, geneva, sans-serif;"><span style="color:#333333;">Hit the link to confirm your shiny, new account and enter <strong>24Bettle </strong>- a new dimension of awesome!</span></span></p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
<tr>
<td align="center" style="word-break:break-word;font-size:0px;padding:10px 25px;">
<table align="center" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr><!-- style="border: 3px solid #4A8FFF;box-shadow: 0px 5px 10px 0px rgba(85,108,108,1);display:inline-block;text-decoration:none;color:white;font-family:Verdana, sans-serif;font-size:22px;text-shadow: 0px 2px 0px #000000;line-height: 20px;font-weight:900;margin:0px; padding:22px 23px; background: transparent linear-gradient(180deg, RGB(118, 191, 254) 44%, #1A3380 97%) 0% 0% no-repeat padding-box; no-repeat:padding-box;border-radius: 35px"-->
<td align="center" bgcolor="" style="border-radius:6px;color:white;cursor:auto;background: url(http://24bettle.com/images/email_images/button-gradient-pic.png);background-size: 100% 100%;" valign="middle">CONFIRM!</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="center" style="word-break:break-word;font-size:0px;padding:0px;">
<div style="cursor:auto;color:#000000;font-family:Verdana, sans-serif;font-size:14px;line-height:14px;">
<div style="text-align: -webkit-center; background-color: rgb(255, 255, 255); cursor: auto; font-family: Verdana, sans-serif; font-size: 14px; line-height: 14px;"> </div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="full-width" style="margin:0 auto;max-width:600px;">
<table align="center" border="0" cellpadding="0" cellspacing="0" class="full-width" style="font-size:0px;width:100%;background:#333333;">
<tbody class="full-width">
<tr>
<td style="text-align:center;vertical-align:top;font-size:0px;padding:0px;">
<div aria-labelledby="mj-column-per-100" class="mj-column-per-100" style="background-color: #333333;vertical-align:middle;display:inline-block;font-size:13px;text-align:center;width:100%;">
<table border="0" cellpadding="0" cellspacing="0" style="vertical-align:middle;" width="100%">
<tbody style="background: #141E30; ">
<tr>
<td align="center" style="word-break:break-word;font-size:0px;padding: 10px 0 0 0;background-color: #333333">
<div style="cursor:auto;color:#CCCCCC;font-family:Verdana, sans-serif;line-height:22px;">
<p style="padding: 0 1em;font-family: 'Segoe UI',sans-serif;font-size: 14px; margin: 0; color: #CCCCCC;text-align: -webkit-center;"> </p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!--[if mso | IE]>
</td></tr></table>
<![endif]--></td>
</tr>
</tbody>
</table>
</div>
<!--[if mso | IE]>
</td></tr></table>
<![endif]--><!--[if mso | IE]>
<table class="full-width" border="0" cellpadding="0" cellspacing="0" width="600" align="center" style="width:600px;">
<tr>
<td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;">
<![endif]-->
<div class="full-width" style="margin:0 auto;max-width:600px;background:#fff;">
<table align="center" border="0" cellpadding="0" cellspacing="0" class="full-width" style="font-size:0px;width:100%;background:#fff;">
<tbody>
<tr>
<td style="text-align:center;vertical-align:top;font-size:0px;padding:0px;"><!--[if mso | IE]>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td style="vertical-align:middle;width:300px;">
<![endif]--><!--[if mso | IE]>
</td>
<td style="vertical-align:middle;width:300px;">
<![endif]--><!--[if mso | IE]>
</td></tr></table>
<![endif]--></td>
</tr>
</tbody>
</table>
</div>
<!--[if mso | IE]>
</td></tr></table>
<![endif]--></div>
</body>
</html>
import com.google.api.client.auth.oauth2.Credential;
import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp;
import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver;
import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow;
import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets;
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.client.repackaged.org.apache.commons.codec.binary.Base64;
import com.google.api.client.repackaged.org.apache.commons.codec.binary.StringUtils;
import com.google.api.client.util.store.FileDataStoreFactory;
import com.google.api.services.gmail.Gmail;
import com.google.api.services.gmail.Gmail.Users;
import com.google.api.services.gmail.Gmail.Users.Messages;
import com.google.api.services.gmail.Gmail.Users.Messages.Get;
import com.google.api.services.gmail.GmailScopes;
import com.google.api.services.gmail.model.Label;
import com.google.api.services.gmail.model.ListLabelsResponse;
import com.google.api.services.gmail.model.ListMessagesResponse;
import com.google.api.services.gmail.model.Message;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.security.GeneralSecurityException;
import java.util.Collections;
import java.util.List;
public class GmailQuickstart {
private static final String APPLICATION_NAME = "Gmail API Java Quickstart";
private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
private static final String TOKENS_DIRECTORY_PATH = "tokens";
/**
* Global instance of the scopes required by this quickstart.
* If modifying these scopes, delete your previously saved tokens/ folder.
*/
private static final List<String> SCOPES = Collections.singletonList(GmailScopes.GMAIL_LABELS);
private static final String CREDENTIALS_FILE_PATH = "/credentials.json";
/**
* Creates an authorized Credential object.
* #param HTTP_TRANSPORT The network HTTP Transport.
* #return An authorized Credential object.
* #throws IOException If the credentials.json file cannot be found.
*/
private static Credential getCredentials(final NetHttpTransport HTTP_TRANSPORT) throws IOException {
// Load client secrets.
InputStream in = GmailQuickstart.class.getResourceAsStream(CREDENTIALS_FILE_PATH);
if (in == null) {
throw new FileNotFoundException("Resource not found: " + CREDENTIALS_FILE_PATH);
}
GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));
// Build flow and trigger user authorization request.
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
.setDataStoreFactory(new FileDataStoreFactory(new java.io.File(TOKENS_DIRECTORY_PATH)))
.setAccessType("offline")
.build();
LocalServerReceiver receiver = new LocalServerReceiver.Builder().setPort(8888).build();
return new AuthorizationCodeInstalledApp(flow, receiver).authorize("user");
}
public static void main(String... args) throws IOException,
// Build a new authorized API client service.
final NetHttpTransport HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
Gmail service = new Gmail.Builder(HTTP_TRANSPORT, JSON_FACTORY, getCredentials(HTTP_TRANSPORT))
.setApplicationName(APPLICATION_NAME)
.build();
// Print the labels in the user's account.
String user = "me";
ListLabelsResponse listResponse = service.users().labels().list(user).execute();
List<Label> labels = listResponse.getLabels();
if (labels.isEmpty()) {
System.out.println("No labels found.");
} else {
System.out.println("Labels:");
for (Label label: labels) {
System.out.printf("- %s\n", label.getName());
}
}
// Access Gmail inbox
Gmail.Users.Messages.List request = service.users().messages().list(user).setQ("from: " + "helpdesk#b-bets.com");
ListMessagesResponse messagesResponse = request.execute();
request.setPageToken(messagesResponse.getNextPageToken());
// Get ID of the email you are looking for
Gmail.Users.Messages.List request = service.users().messages().list(user).setQ("from: " + "support1#24bettle.com");
String messageId = messagesResponse.getMessages().get(0).getId();
Message message = service.users().messages().get(user, messageId).execute();
// Print email body
String emailBody = StringUtils
.newStringUtf8(Base64.decodeBase64(message.getPayload().getParts().get(0).getBody().getData()));
System.out.println("Email body : " + emailBody);
}
}
Issue:
The HTML table you are looking for is in a subpart of the message's first part.
Explanation:
The response you are getting from Try this API has this approximate shape (excluding irrelevant fields):
{
"payload": {
"body": { "size": 0 },
"parts": [
{
"partId": "0",
"body": { "size": 0 },
"parts": [
{
"partId": "0.0",
// Other fields
},
{
"partId": "0.1",
"mimeType": "text/html",
"body": {
"size": 14024,
"data": "BASE64_ENCODED_STRING" // HTML table
},
// Other fields
}
]
},
{
"partId": "1",
// Other fields
}
]
},
// Other fields
}
If you look at this, it's clear that the content you are looking for is in the first part, but this part itself contains several subparts. The second of these parts contains the desired content.
Solution:
You should be able to retrieve the data from this part via:
message.getPayload().getParts().get(0).getParts().get(1).getBody().getData();
Therefore, replace this:
String emailBody = StringUtils
.newStringUtf8(Base64.decodeBase64(message.getPayload().getParts().get(0).getBody().getData()));
With this:
String emailBody = StringUtils
.newStringUtf8(Base64.decodeBase64(message.getPayload().getParts().get(0).getParts().get(1).getBody().getData()));
Reference:
MessagePart
I am trying to identify the td value, the thing is inside TD i have input tag and i need to identify the value. My Td tag looks like below. I need to identify and get the value 4/11/2016. Trying to add the full source code
<div id="accountsSectionBottomContainer" class="acctBottom" default-path="/ui/app.php/AccountsBottomPane/21/acct_glance">
<div>
<div class="accountsModPLSQLReturn" data-aria-plsql-root="/ui/mod_plsql.php/aria/csrtools/" data-aria-plsql-url="dashboard_plan.plan_inst_unit_inst_dtls">
<div class="workbook_tabname">Accounts</div>
<script language="JavaScript" type="text/javascript"> self.focus(); </script>
<div id="account-name">
<style type="text/css"> .color-block dl { background-color: #F8F8FF; margin: 0; padding: 1em; } .white-block dl { font-size: 1.1em; margin: 0; padding: 1em; } .static-block dt { float: left; font-size: 1.1em; font-weight: bold; margin: 0; padding: 0; width: 300px; } .static-block dd { font-size: 1.1em; margin: 0 0 0 225px; padding: 0 0 5px 15px; } </style>
<script language="javascript" type="text/javascript"> $('.trgprdval').trigger('change'); var inFulfilmentStartDate_cal = new calendar3(document.main.inFulfillmentDate, "MM/DD/YYYY"); inFulfilmentStartDate_cal.year_scroll = true; inFulfilmentStartDate_cal.time_comp = false; function myCdidFunction() { var newCDID = document.getElementById('inClientDefinedIdentifier').value; document.getElementById('inNewCdid').value = newCDID; } function copyRadioVal(inputValue, origVal, inputName, name) { var hiddenValues = document.getElementsByClassName(name); console.log(inputName); console.log(name); console.log(document.getElementById(inputName)); x = document.getElementById(inputName).checked; if (x==true) { $("#"+origVal).val(inputValue); } } function copyCheckboxVal(inputValue, origVal, inputName, inPrimacyNo, inputId) { var x = document.getElementById(inputName).checked; if (x==true) { document.getElementById(origVal).value = inputValue; } if (x==false) { document.getElementById(origVal).value = ""; } var inputType = inPrimacyNo.concat(inputId); document.getElementById(inputType).value = inPrimacyNo; } function joinSelectVal(newInputName, oldInputId) { var selectval = document.forms["main"][oldInputId]; var selectedList = []; for (var i = 0; i < selectval.length; i++) { if (selectval[i].selected) { selectedList.push(selectval[i].value); } } var checkedStr = Array.join(selectedList, "~"); if (checkedStr.length == 0) { checkedStr = "NO#VALUE"; } document.getElementById(newInputName).value = checkedStr; } function validateInputsAndSubmit(button) { var valSuppFields = validateAcctSuppFields('.accountsForm'); if(!valSuppFields['isValid']) { alert(valSuppFields['errorMsg']); return false; } lockAndSubmitForm(button); } </script>
<div class="color-block">
<div class="white-block">
<form class="accountsForm" name="main" method="post" action="/ui/mod_plsql.php/aria/csrtools/dashboard_plan_m.plan_unit_instance_save_m" onsubmit="return false;">
<font size="3">
<br/>
<br/>
<table class="data-table clear-both" cellspacing="0">
<colgroup>
<tbody>
<tr>
<tr class="dataRow1 even">
<td valign="top" style="text-align: left;">
<td valign="top" style="text-align: left;">10089723</td>
<td valign="top" style="text-align: left;">Yes</td>
<td valign="top" style="text-align: left;">Invoiced</td>
<td valign="top" style="text-align: left;">
<input type="hidden" value="10089723" name="INSERVICES[0][inServiceNo]"/>
<input type="hidden" value="1" name="INSERVICES[0][inFulfillmentStatus]"/>
<input type="hidden" value="1" name="INSERVICES[0][inFulfillmentBasedInd]"/>
<input id="inFulfillmentDate10089723" type="text" readonly="readonly" value="4/11/2016" name="INSERVICES[0][inFulfillmentDate]"/>
</td>
</tr>
<tr class="dataRow1 even">
<td valign="top" style="text-align: left;">
<td valign="top" style="text-align: left;">10089726</td>
<td valign="top" style="text-align: left;">Yes</td>
<td valign="top" style="text-align: left;">Invoiced</td>
<td valign="top" style="text-align: left;">
<input type="hidden" value="10089726" name="INSERVICES[1][inServiceNo]"/>
<input type="hidden" value="1" name="INSERVICES[1][inFulfillmentStatus]"/>
<input type="hidden" value="1" name="INSERVICES[1][inFulfillmentBasedInd]"/>
<input id="inFulfillmentDate10089726" type="text" readonly="readonly" value="4/11/2016" name="INSERVICES[1][inFulfillmentDate]"/>
</td>
</tr>
<tr class="dataRow1 even">
<td valign="top" style="text-align: left;">
<td valign="top" style="text-align: left;">10089727</td>
<td valign="top" style="text-align: left;">Yes</td>
<td valign="top" style="text-align: left;">Invoiced</td>
<td valign="top" style="text-align: left;">
<input type="hidden" value="10089727" name="INSERVICES[2][inServiceNo]"/>
<input type="hidden" value="1" name="INSERVICES[2][inFulfillmentStatus]"/>
<input type="hidden" value="1" name="INSERVICES[2][inFulfillmentBasedInd]"/>
<input id="inFulfillmentDate10089727" type="text" readonly="readonly" value="4/11/2016" name="INSERVICES[2][inFulfillmentDate]"/>
</td>
</tr>
<tr class="dataRow1 even">
<td valign="top" style="text-align: left;">
<td valign="top" style="text-align: left;">10089730</td>
<td valign="top" style="text-align: left;">Yes</td>
<td valign="top" style="text-align: left;">Invoiced</td>
<td valign="top" style="text-align: left;">
<input type="hidden" value="10089730" name="INSERVICES[3][inServiceNo]"/>
<input type="hidden" value="1" name="INSERVICES[3][inFulfillmentStatus]"/>
<input type="hidden" value="1" name="INSERVICES[3][inFulfillmentBasedInd]"/>
<input id="inFulfillmentDate10089730" type="text" readonly="readonly" value="4/11/2016" name="INSERVICES[3][inFulfillmentDate]"/>
</td>
</tr>
<tr class="dataRow1 even">
<td valign="top" style="text-align: left;">
<td valign="top" style="text-align: left;">10089747</td>
<td valign="top" style="text-align: left;">Yes</td>
<td valign="top" style="text-align: left;">Invoiced</td>
<td valign="top" style="text-align: left;">
<input type="hidden" value="10089747" name="INSERVICES[4][inServiceNo]"/>
<input type="hidden" value="1" name="INSERVICES[4][inFulfillmentStatus]"/>
<input type="hidden" value="1" name="INSERVICES[4][inFulfillmentBasedInd]"/>
<input id="inFulfillmentDate10089747" type="text" readonly="readonly" value="4/11/2016" name="INSERVICES[4][inFulfillmentDate]"/>
</td>
</tr>
</tbody>
</table>
<br/>
<br/>
<font size="3">
<br/>
<br/>
<table class="simple" cellspacing="0">
<input type="hidden" value="8179" name="inPlanNo"/>
<input type="hidden" value="4066308" name="inPlanUnitInstanceNo"/>
<input id="inNewCdid" type="hidden" name="inClientDefinedIdentifier"/>
<input type="hidden" value="MasterPlan" name="inSelectedPlan"/>
<input type="hidden" value="19328197" name="inPlanInstanceNo"/>
<div class="form-buttons">
<input type="hidden" value="AAAAAAUJTTz9lWKS_TgqUANHCenOnmxH2IQHclhl2zoruTE55z7CFHIdaAAJNyGlNLLnb5f-97HVxpFchLgkkTjIFz9d_I_sKfI7EQd83gmsfyFtQA==" name="as_sfid"/>
<input type="hidden" value="yli8W38Xf7v_849HentO" name="as_fid"/>
</form>
</div>
</div>
</div>
<input id="inFulfillmentDate10089723" type="text" readonly="readonly" value="4/11/2016" name="INSERVICES[0][inFulfillmentDate]"/>
</td>
Hi in case you want to identify value="4/11/2016" you can directly use
in case of dynamic id plz use like
MyDynamicID = "//*[starts-with(#id,'inFulfillmentDate')]"
String value = driver.findElement(By.id(MyDynamicID )).getText();
now print string in the console
UPADTE
// our id = inFulfillmentDate pattern
List<WebElement> myDate = driver.findElements(By.xpath("//*[starts-with(#id,'inFulfillmentDate')]"));
System.out.println(myDate.size());
// now print all value
for(int i=0;i<myDate.size();i++){
System.out.println("value is : " +myDate.get(i).getAttribute("value"));
}
Belwo is the console output
6
value is : 4/11/2016
value is : 4/11/2016
value is : 4/11/2016
value is : 4/11/2016
value is : 4/11/2016
value is : 4/11/2016
I'm trying to write a code that stores images into database, then later display it on the webpage using the rollnum to retrieve it from the database. I've tried all i could but still no good, i tried reading some tutorials but still no good, anyways here's the code i'm working on. I'd be very grateful if someone could help, Thanks in Advance.
<%#page import="java.sql.*" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Registration Page</title>
<style>
body{
background-image: url('bg.png');
background-repeat: repeat;
font-family: Courier New;
margin:auto;
width: 1000px;
}
.wrap{
margin-top:10px;
border:solid 1px #000;
height:900px;
}
.header{
font-size: 50px;
font-weight: bold;
font-family: Courier New;
text-align: center;
}
.border{
border-bottom: solid 1px #000;
margin-left: 30px;
margin-right: 30px;
}
.box{
border: solid 1px #000;
padding: 8px;
margin: 30px;
}
</style>
</head>
<body>
<div class="wrap">
<table>
<form method="post">
<br/>
<tr>
<td> Roll Number:</td> <td><input type="text" name="rollnum"/></td>
</tr>
</div>
<tr>
<td> First Name:</td> <td><input type="text" name="fname"/></td>
</tr>
<tr>
<td> Last Name:</td> <td><input type="text" name="lname"/></td>
</tr>
<tr>
<td> Course Name:</td> <td><input type="text" name="course"/></td>
</tr>
<tr>
<td> Gender:</td> <td>Male:<input type="radio" name="gender" value="Male"/> Female:<input type="radio" name="gender" value="Female"/></td>
</tr>
<tr>
<td> Address:</td> <td><input type="text" name="addr"/></td>
</tr>
<tr>
<td> State:</td> <td><input type="text" name="state"/></td>
</tr>
<tr>
<td> Photo:<input type="file" name="photo"/></td>
</tr>
<tr>
<td> <input type="submit" value="Submit" name="submit"/></td>
</tr>
</form>
</table>
<%
try{
if(request.getParameter("submit") != null){
Connection conn;
PreparedStatement prep;
String sql;
String url = "jdbc:derby://localhost:1527/reg";
Class.forName("org.apache.derby.jdbc.ClientDriver");
conn = DriverManager.getConnection(url,"uname","pass");
sql =
"insert into student (rollnum,fname,lname,course,gender,addr,state,photo)"
+"values(?,?,?,?,?,?,?,?)";
ResultSet rs = null;
prep = conn.prepareStatement(sql);
prep.setInt(1, Integer.parseInt(request.getParameter("rollnum")));
prep.setString(2, request.getParameter("fname"));
prep.setString(3, request.getParameter("lname"));
prep.setString(4, request.getParameter("course"));
prep.setString(5, request.getParameter("gender"));
prep.setString(6, request.getParameter("addr"));
prep.setString(7, request.getParameter("state"));
//prep.setString(8, request.getParameter("photo"));
Blob blob = rs.getBlob(request.getParameter("photo"));;
prep.setBlob(8, blob);
int n = prep.executeUpdate();
if(n>0){
%>
<div class="box">Registration Successful!! <b>Login Now!!</b></div>
<%
}
}
}
catch(ClassNotFoundException e){
}
catch(NumberFormatException n){
}
%>
</div>
</body>
You can follow this way:
Get the image
Convert the image with the base64 rappresentation
Store the base64 into your db
when you need the image convert again the base64 into the image
I am looking for any GWT grid widget that needs to have row and column headers on X and Y axis. Those needs to be seamlessly scrollable across X and Y axis.
Essentially I am looking for a GWT widget as demonstrated in the below URL
jsfiddle.net/jschlick/Gv26h/
We need to prifix with http:// in the above URL. The above is completely implemented in Java script.
Is there any GWT widget available with above functionality?
Any help would be really appreciated.
<html>
<header>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style>
body, input {
/*font: 15px/1em Arial, Helvetica, sans serif;*/
}
-webkit-scrollbar {
height: 7px;
width: 7px;
-webkit-appearance: none;
}
-webkit-scrollbar-thumb {
background-color: rgba(0,0,0,.5);
border-radius: 4px;
-webkit-box-shadow: 0 0 1px rgba(255,255,255,.5);
}
#divHeader {
border-bottom: 1px solid #d7d7d7;
overflow: hidden;
padding: 0 0 5px 0;
width: 284px;
}
#firstcol {
border-right: 1px solid #d7d7d7;
height: 200px;
overflow: hidden;
padding: 0 10px;
}
#table_div {
height: 210px;
overflow: scroll;
position: relative;
width: 300px;
}
#table_div td {
}
</style>
<script type='text/javascript' src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
fnAdjustTable();
});
fnAdjustTable = function(){
var colCount = $('#firstTr>td').length; //get total number of column
var m = 0;
var n = 0;
var brow = 'mozilla';
jQuery.each(jQuery.browser, function(i, val) {
if(val == true){
brow = i.toString();
}
});
$('.tableHeader').each(function(i){
if (m < colCount){
if (brow == 'mozilla'){
$('#firstTd').css("width",$('.tableFirstCol').innerWidth());//for adjusting first td
$(this).css('width',$('#table_div td:eq('+m+')').innerWidth());//for assigning width to table Header div
}
else if (brow == 'msie'){
$('#firstTd').css("width",$('.tableFirstCol').width());
$(this).css('width',$('#table_div td:eq('+m+')').width()-2);//In IE there is difference of 2 px
}
else if (brow == 'safari'){
$('#firstTd').css("width",$('.tableFirstCol').width());
$(this).css('width',$('#table_div td:eq('+m+')').width());
}
else {
$('#firstTd').css("width",$('.tableFirstCol').width());
$(this).css('width',$('#table_div td:eq('+m+')').innerWidth());
}
}
m++;
});
$('.tableFirstCol').each(function(i){
if(brow == 'mozilla'){
$(this).css('height',$('#table_div td:eq('+colCount*n+')').outerHeight());//for providing height using scrollable table column height
}
else if(brow == 'msie'){
$(this).css('height',$('#table_div td:eq('+colCount*n+')').innerHeight()-2);
}
else {
$(this).css('height',$('#table_div td:eq('+colCount*n+')').height());
}
n++;
});
}
//function to support scrolling of title and first column
fnScroll = function(){
$('#divHeader').scrollLeft($('#table_div').scrollLeft());
$('#firstcol').scrollTop($('#table_div').scrollTop());
}
</script>
</header>
<body>
<table cellspacing="0" cellpadding="0" border="1" >
<tr>
<td id="firstTd">
</td>
<td>
<div id="divHeader">
<table cellspacing="0" cellpadding="10" border="1">
<tr>
<td>
<div class="tableHeader">28</div>
</td>
<td>
<div class="tableHeader">30</div>
</td>
<td>
<div class="tableHeader">32</div>
</td>
<td>
<div class="tableHeader">34</div>
</td>
<td>
<div class="tableHeader">36</div>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td valign="top">
<div id="firstcol">
<table cellspacing="0" cellpadding="10" border="1">
<tr>
<td class="tableFirstCol">32</td>
</tr>
<tr>
<td class="tableFirstCol">32.5</td>
</tr>
<tr>
<td class="tableFirstCol">33</td>
</tr>
<tr>
<td class="tableFirstCol">33.5</td>
</tr>
<tr>
<td class="tableFirstCol">34</td>
</tr>
<tr>
<td class="tableFirstCol">34.5</td>
</tr>
<tr>
<td class="tableFirstCol">36</td>
</tr>
<tr>
<td class="tableFirstCol">36.5</td>
</tr>
<tr>
<td class="tableFirstCol">38</td>
</tr>
</table>
</div>
</td>
<td valign="top">
<div id="table_div" onscroll="fnScroll()" >
<table width="500px" cellspacing="0" cellpadding="10" border="1">
<tr id="firstTr">
<td>Row1Col1</td>
<td>Row1Col2</td>
<td>Row1Col3</td>
<td>Row1Col4</td>
<td>Row1Col5</td>
</tr>
<tr>
<td>Row2Col1</td>
<td>Row2Col2</td>
<td>Row2Col3</td>
<td>Row2Col4</td>
<td>Row2Col5</td>
</tr>
<tr>
<td>Row3Col1</td>
<td>Row3Col2</td>
<td>Row3Col3</td>
<td>Row3Col4</td>
<td>Row3Col5</td>
</tr>
<tr>
<td>Row4Col1</td>
<td>Row4Col2</td>
<td>Row4Col3</td>
<td>Row4Col4</td>
<td>Row4Col5</td>
</tr>
<tr>
<td>Row5Col1</td>
<td>Row5Col2</td>
<td>Row5Col3</td>
<td>Row5Col4</td>
<td>Row5Col5</td>
</tr>
<tr>
<td>Row6Col1</td>
<td>Row6Col2</td>
<td>Row6Col3</td>
<td>Row6Col4</td>
<td>Row6Col5</td>
</tr>
<tr>
<td>Row7Col1</td>
<td>Row7Col2</td>
<td>Row7Col3</td>
<td>Row7Col4</td>
<td>Row7Col5</td>
</tr>
<tr>
<td>Row8Col1</td>
<td>Row8Col2</td>
<td>Row8Col3</td>
<td>Row8Col4</td>
<td>Row8Col5</td>
</tr>
<tr>
<td>Row9Col1</td>
<td>Row9Col2</td>
<td>Row9Col3</td>
<td>Row9Col4</td>
<td>Row9Col5</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</body>
</html>
I am getting this error while I am trying to render a pdf. I am using Nicolas Leroux's PDF module for the play framework.
This is the entire stackstrace: Pastebin. Googling only reveals 4 results. They suggest removing any float properties, and position attributes, which I have removed, jsut to give it a try. I am still facing this problem. Has anyone been able to solve the issue?
EDIT: This is the html that renders the pdf:
#{extends 'main.html' /} #{set title:'Salary Details' /}
<html>
<head>
<title>Employee Name</title>
<style>
body {
font: 9pt Arial, Helvetica, sans-serif;
}
.container {
margin: 0 auto;
width: 1000px;
border: 1px solid black;
padding: 12px;
}
.logoClass {
width: 200px;
height: 85px;;
}
.companyAddressClass {
width: 60%;
margin: 0 auto;
font-size: 17px;
font-weight: bold;
text-align: center;
}
.empClass table {
width: 100%;
border: 1px solid #ccc;
border-collapse: collapse;
margin: 10px 0px;
}
.empClass table th,td {
border: 1px solid #ccc;
padding: 5px 5px;
}
.empClass table th {
background: #f2f2f2;
}
</style>
</head>
<body onload="window.print();">
%{for(int i=0;i<dataList.size ();i=i+1){}%
<div class="container" style="page-break-after:#{if i == dataList.size()-1} avoid;#{/if} #{else} always; #{/else}">
<div class="logoClass"></div>
<div class="companyAddressClass">
${dataList.get(i).distributorName},<br /> ${dataList.get(i).city},<br />
${dataList.get(i).state} <br /> <br /> <span>Payslip for the
month of ${dataList.get(i).salaryMonth}</span>
</div>
<br class="clear" />
<div class="empClass">
<table border="1">
<tr>
<td>Employee No: ${dataList.get(i).employeeNumber}</td>
<td>Location: ${dataList.get(i).location}</td>
</tr>
<tr>
<td>Name: ${dataList.get(i).employeeName}</td>
<td>Salary for the M/O: ${dataList.get(i).salaryMonth}</td>
</tr>
<tr>
<td>Bank Name: ${dataList.get(i).bankName}</td>
<td>Designation: ${dataList.get(i).designation}</td>
</tr>
<tr>
<td>Bank Acc No: ${dataList.get(i).accountNumber}</td>
<td>Join Date: ${dataList.get(i).joinDate}</td>
</tr>
<tr>
<td>PF No: ${dataList.get(i).pfNumber}</td>
<td>Gender: ${dataList.get(i).gender}</td>
</tr>
<tr>
<td>ESI No: ${dataList.get(i).esiNumber}</td>
<td>LOP: ${dataList.get(i).lop}</td>
</tr>
<tr>
<td>PAN No: ${dataList.get(i).panNumber}</td>
<td>Days Worked: ${dataList.get(i).daysWorked}</td>
</tr>
</table>
</div>
<br />
<div class="empClass">
<table border="1">
<tr>
<th colspan="3">Earnings</th>
<th colspan="2">Deductions</th>
</tr>
<tr>
<th align="left">Header</th>
<th align="right">Actual</th>
<th align="right">Paid</th>
<th align="left">Header</th>
<th align="right">Paid</th>
</tr>
<tr>
<td>Basic</td>
<td align="right">${dataList.get(i).basic}</td>
<td align="right">${dataList.get(i).basic}</td>
<td>PF</td>
<td align="right">${dataList.get(i).pf}</td>
</tr>
<tr>
<td>HRA</td>
<td align="right">${dataList.get(i).hra}</td>
<td align="right">${dataList.get(i).hra}</td>
<td>ESICEE</td>
<td align="right">${dataList.get(i).esicee}</td>
</tr>
<tr>
<td>Conveyance Allowance</td>
<td align="right">${dataList.get(i).conveynanceAllowance}</td>
<td align="right">${dataList.get(i).conveynanceAllowance}</td>
<td>ESICEE(PWS)</td>
<td align="right">${dataList.get(i).esiceePWS}</td>
</tr>
<tr>
<td>Medical Allowance</td>
<td align="right">${dataList.get(i).medicalAllowances}</td>
<td align="right">${dataList.get(i).medicalAllowances}</td>
<td>PT</td>
<td align="right">${dataList.get(i).pt}</td>
</tr>
<tr>
<td>Special Allowance</td>
<td align="right">${dataList.get(i).specialAllowance}</td>
<td align="right">${dataList.get(i).specialAllowance}</td>
<td>PT(PWS)</td>
<td align="right">${dataList.get(i).ptPWS}</td>
</tr>
<tr>
<td>Incentives</td>
<td align="right">${dataList.get(i).midMonthAmountPWS}</td>
<td align="right">${dataList.get(i).midMonthAmountPWS}</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Other Allowances</td>
<td align="right">${dataList.get(i).otherAllowance}</td>
<td align="right">${dataList.get(i).otherAllowance}</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="3" align="right">Total
Earnings:${dataList.get(i).totalEarnings}</td>
<td colspan="2" align="right">Total Deduction
:${dataList.get(i).totalDeduction}</td>
</tr>
<tr>
<td colspan="3"> </td>
<td colspan="2" align="right"><strong>Salary Credited
: ${dataList.get(i).salaryCredited}</strong></td>
</tr>
</table>
<table>
<thead>
<tr>
<th>Position Title</th>
<th>City Name</th>
<th>State Name</th>
</tr>
</thead>
<thead>
<tr>
..
..
..
..
<th>${dataList.get(i).positionTitle}</th>
<th>${dataList.get(i).cityName}</th>
<th>${dataList.get(i).stateName}</th>
</tr>
</thead>
</table>
<br>
<table>
<thead>
<tr>
<th>Some Header</th>
<th>Some Header</th>
<th>Some Header</th>
<th>Some Header</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">Values</td>
..
..
..
..
..
</tr>
</tbody>
</table>
</div>
<div>
<span style="font-size: 15px; font-weight: bold;"> Salary
Credited Amount(In Words): ${dataList.get(i).salaryCreditedInWord} </span>
</div>
</div>
<br />
<br />
%{}}%
</body>
</html>
I am using Windows 7 and Tomcat6 as the testing environment, the same environment that people over here are facing trouble with.
Thanks.
This commit is a fix for your problem. You can download the whole class and put it in your source code, so you haven't to rebuild the library jar.
If you are facing this issue, to fix this just add a span tag inside the td and add the style to that span tag. Example:
<td>
<span style = style="position: absolute;">
</td>
Basically if you add the style to the td, you would get the error because of the bug in fly saucer pdf.