When expanding a HTML page with embedded variables from JSP code my code produced inexplicable results. The variable "String completename" expands at first to
http://www.formatika.de/cococo.de/products/Sources/Isabelle/Doc/Tutorial/document/Isa-logics.pdf
and 2 lines later to
http://localhost:8080/cococo.de/products/Sources/Isabelle/Doc/Tutorial/document/Isa-logics.pdf
in the following code fragment:
<div>
<table border="0" align="center" cellspacing="2" cellpadding="2">
<tr align="center"><td align="center">
<div>
<a href="<%=completename %>" title="<%=showname%>" target="_blank"><%=filename%><br><br>
<iframe src='<%=completename %>' width='<%=width%>' height='<%=height%>' type='application/pdf'>
</iframe>
</a>
</div>
</td></tr>
</table>
</div>
it can be observed in this URL
http://formatika.de/print.jsp?content=source&file=products/Sources/Isabelle/Doc/Tutorial/document/Isa-logics.pdf
Does anyone know where to search? I use Apache Tomcat 8.0.27 with JAVA EE 6 Web.
Found the answer/bug; it was because the Tomcat still is hidden behind the IIS and therefore the name was here resolved to "localhost:8080" instead of the hostname at IIS.
Related
I am not able to access the webtable elements inside the table2 , please see the page source below :
<table id="table1">
<tr class="head">
<td class="left" colspan="2">
<!--PAGE LINKS-->
</td>
</tr>
<tr>
<td class="left_link">
<h1>
<a name="nav_home" href="index.html" id="home_link" class="home">HOME</a><br>
<a name="nav_adopt" href="adoption.html" id="adoption_link">ADOPTION</a><br>
<a name="nav_about" href="about.html" id="about_link">ABOUT</a><br>
<a name="nav_contact" href="contact.html" id="contact_link">CONTACT</a><br>
</h1>
</td>
<td class="content">
<h1>
CONTACT US
</h1>
<hr>
<p>
Use the form below to contact us if you have any questions, queries or even any requests.
We are always happy to hear from you all.
</p>
<h1 class="subhead">Contact Form</h1>
<form name="message_form">
<table id="table2" class="inner_table">
<tr>
<td>Enter Name</td>
<td><input type="text" name="name_field"></td>
</tr>
<tr>
<td></td>
<td>
<input type="radio" id="rinfo" name="rbutton" value="information">Information
<input type="radio" id="rdona" name="rbutton" value="Donation">Donation
<input type="radio" id="radop" name="rbutton" value="Donation">Adoption
</td>
</tr>
For example i am not able to access the name inside the table2.
I tried accessing using below but failed .
driver.findElements(By.xpath("//*[#class='table1']/tbody/tr[2]/td[2]/form/table[#class='inner_table']/tr[1]/td[1))
Try this below xpath
//table[#id='table2']/..//following::input[#name='name_field']
Explanation of xpath:- Use id attribute of <table> tag and move ahead with <input> tag using following keyword.
This above xpath will locate the Enter Name field text box.
Note:- Instead of using absolute xpath, Use relative xpath.
It is not recommended to use xpath on selenium, since elements might tend to change and you have to refactor your selector if you add another element.
To answer your question, you can use the id for table2 and select the desired element.
It should be a CSS selector as simple as input[name='name_field'] or if that isn't specific enough, use #table2 input[name='name_field'].
Try xpath like below:
to access input filed with name 'name_field' use below xpath
driver.findElement(By.xpath("//table[#id='table2' and #class= 'inner_table']//input[#type='text' and #name='name_field']")
Hope it will help.
In web tables, you can use xPath to reach parent of an element and then finding the preceding-sibling or the following-sibling of td tags
This tutorial will help you:
http://www.seleniumtests.com/2011/10/using-xpath-to-reach-parent-of-element.html
I have the following basic html table with a Java function to print only the table content However the Print button does nothing when clicked,I figure probably the java coding is the issue, however it is not working could I get a third pair of eyes to assist please
<html>
<body>
<table border="1" cellpadding="3" id="printTable">
<tbody><tr>
<th>First Name</th>
<th>Last Name</th>
<th>Points</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
<td>80</td>
</tr>
<tr>
<td>Adam</td>
<td>Johnson</td>
<td>67</td>
</tr>
</tbody></table>
<br />
<br />
<button>Print me</button>
<script>
function printData()
{
var divToPrint=document.getElementById("printTable");
newWin= window.open("");
newWin.document.write(divToPrint.outerHTML);
newWin.print();
newWin.close();
}
$('button').on('click',function(){
printData();
})
</script>
</body>
</html>
When working with javascript, it is often useful to look at your browser's console. After opening this page, mine has the error:
ReferenceError: $ is not defined
$ is a global variable inserted by jQuery. Try adding
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
to the code. This will include the jQuery library.
The call to the javascript function is not correct. When you're using the '$' symbol it means that you're using JQuery. You have 2 options:
1 - Include the jquery library to your page:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
2 - Call the javascript function directly on the button on the 'onclick' event. This is the best option in your case:
<button onclick="printData()">Print me</button>
Change this var divToPrint=document.getElementById("printTable");
to this var divToPrint=document.getElementById("<%=printTable.ClientID>");
and add jquery library <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
I have the following html string content and i want to convert it into java map using java.
<div dir="ltr"><div class="gmail_quote"><div dir="ltr"><div><div dir="ltr"><div><p style="font-family:arial,sans-serif;font-size:13px">Notification for shipment event group "Picked up" for 13 May 14.<u></u><u></u></p>
<div class="MsoNormal" align="center" style="font-family:arial,sans-serif;font-size:13px;text-align:center">
<hr size="2" width="100%" align="center"></div><table border="0" cellpadding="0" style="font-family:arial,sans-serif;font-size:13px">
<tbody><tr><td style="padding:0.75pt">
<p class="MsoNormal">
AWB Number: 8841965182<br>
Pickup Date: 2014-05-13 20:11:00<br>
Service: P<br>
Pieces: 1<br>
enter code here`
I have used jsoup but did not worked.
Take a look at Boilerpipe
A similar question is asked here at SO
My HTML LOGIN Page
<html>
<head>
<title>FormBased Authentication Demo in WebLogic Sample</title>
</head>
<body bgcolor=maroon text=white>
<center>
<h2>Please Enter Your UserName & Password (FormBased Auth Example)</h2>
<form method="POST" action="j_security_check">
<table border=5%>
<tr>
<td>Username:</td>
<td><input type="text" name="j_username"></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="j_password"></td>
</tr>
<tr>
<td colspan=2 align=right><input type=submit value="Submit"></td>
</tr>
</table>
</form>
</center>
</body>
</html>
j_security_check is like a servlet provided by weblogic for implementing SQLAuthencticatoin.
Now I want to call the j_security_check servlet from within a servlet(my own custom servlet) as I need to execute some more code before routing it to j_security_check. Can anyone help me out ?
j_security_check is used in Form-Based Authentication. So you can just do a POST to the j_security_check with "j_username" and "j_password". Typically this is done on a JSP, but it could be done within a servlet as well. This part probably isn't news, but as it is a little unclear what your particular issue is, I would recommend that you check out filters and listeners. If you have some code that you want to run through prior to a particular servlet gets called or preforms a particular action, implementing a listener might just do the trick. Conversely, if you care about managing various things prior to a session getting created, perhaps a filter would be useful.
I am a beginner with jsp servlets, and I need some help having my page not show up blank when I make changes. I am trying to include the the code from a donate-box.jsp into the layout of the org-about-panel.jsp page, which itself is included in another view jsp file. When I makes change to donate-box, then load the view file, I am seeing a blank site, and then upon refreshing, it shows up as before without the donate-box.
Here is the code I am trying to include, from the donate-box:
<logic:notEqual name="hideDonateBox" value="true">
<form action="https://<%=request.getServerName()%><%=contextPath%>/cartDonate.do method="get">
<input type="hidden" name="targetPage" value="<%=requestedPathWithQuery%>">
<div class="donateBox">
<logic:notEmpty name="detailOrgBean" property="offerings">
<table class="donateBox" cellpadding="0" cellspacing="0">
<logic:iterate name="detailOrgBean" property="relatedOfferings" id="receiver" indexId="oppIndex" length="5">
<tr class="donateBox">
<td class="donateBox">
<input type="radio" name="receiverId"
value="<bean:write name="receiver" property="id"/>">
</td>
<th class="donateBox" align="right">
$ -
/donate/<%= formatter.getUrlPath((Receiver) receiver) %>">
" CHECKED>
">
$ (Other)
This file is being included in another file with this code. I have tried commenting out the logic:notequal or logic:empty tags.
<%# include file="/templates/donate-box.jsp" %>
Thanks in advance!
This problems appears because your jsp (donate-box) can't be compiled (Such behavior I've seen in tomcat).
From quick look, I can say that requestedPathWithQuery - variable is undefined in scripting.
For more precise description you can take a look in logs