Thursday, 3 October 2013

Why I should define a JLabel before a addActionListener?

Why I should define a JLabel before a addActionListener?

I have one JLabel and one JButton into JFrame. I write code for
actionPerformed event of JButton like following:
btnOK.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
lblA.setText("Hello"); // error here
}
});
final JLabel lblA = new JLabel("");
but i get following error:
lblA cannot be resolved
however if I placed define of JLabel before addActionListener like
following my problem solved:
final JLabel lblA = new JLabel("");
btnOK.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
lblA.setText("Hello"); // error here
}
});

Wednesday, 2 October 2013

Create class that reads in two names and outputs

Create class that reads in two names and outputs

Create a new program Reverse.java by creating a new class that reads in
two names and outputs them in reverse order. You will need two String
variables name0 and name1 and you will need to use two input dialog boxes.
Don't forget to add a space between the names in the output.
how can i do this?
ThX

Get value with jsoup from webpage

Get value with jsoup from webpage

I am new with Jsoup Current i want to get value of option but i can not.
Here is source of html page:
<div class="entrypost">
Xem nhanh:
<select onchange="window.location.href=this.value;">
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-1.html"
selected="selected"> Kim chi và c&#7911; c&#7843;i ph&#7847;n
1</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-2.html"
>Kim chi và c&#7911; c&#7843;i
ph&#7847;n 2</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-3.html"
>Kim chi và c&#7911; c&#7843;i
ph&#7847;n 3</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-4.html"
>Kim chi và c&#7911; c&#7843;i
ph&#7847;n 4</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-5.html"
>Kim chi và c&#7911; c&#7843;i
ph&#7847;n 5</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-6.html"
>Kim chi và c&#7911; c&#7843;i
ph&#7847;n 6</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-7.html"
>Kim chi và c&#7911; c&#7843;i
ph&#7847;n 7</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-8.html"
>Kim chi và c&#7911; c&#7843;i
ph&#7847;n 8</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-9.html"
>Kim chi và c&#7911; c&#7843;i
ph&#7847;n 9</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-10.html"
>Kim Chi và C&#7911; C&#7843;i
Ph&#7847;n 10</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-11.html"
>Kim Chi và C&#7911; C&#7843;i
Ph&#7847;n 11</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-12.html"
>Kim Chi và C&#7911; C&#7843;i
Ph&#7847;n 12</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-13.html"
>Kim Chi và C&#7911; C&#7843;i
Ph&#7847;n 13</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-14.html"
>Kim Chi và C&#7911; C&#7843;i
Ph&#7847;n 14</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-15.html"
>Kim Chi và C&#7911; C&#7843;i
Ph&#7847;n 15</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-16.html"
>Kim Chi và C&#7911; C&#7843;i
Ph&#7847;n 16</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-17.html"
>Kim Chi và C&#7911; C&#7843;i
Ph&#7847;n 17</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-18.html"
>Kim Chi và C&#7911; C&#7843;i
Ph&#7847;n 18</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-19.html"
>Kim Chi và C&#7911; C&#7843;i
Ph&#7847;n 19</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-20.html"
>Kim Chi và C&#7911; C&#7843;i
Ph&#7847;n 20</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-21.html"
>Kim Chi và C&#7911; C&#7843;i
Ph&#7847;n 21</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-22.html"
>Kim Chi và C&#7911; C&#7843;i
Ph&#7847;n 22</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-23.html"
>Kim Chi và C&#7911; C&#7843;i
Ph&#7847;n 23</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-24.html"
>Kim Chi và C&#7911; C&#7843;i
Ph&#7847;n 24</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-25.html"
>Kim Chi và C&#7911; C&#7843;i
Ph&#7847;n 25</option>
Here is my code: Document doc =
Jsoup.parse("http://truyenhay.vn/kim-chi-va-cu-cai-phan-1.html");
// get all link
Elements elements1 = doc.select("option[value]");
Elements elements2 = elements1.select("value");
System.out.println("DDDDDDD " +elements1.size());
please help me if you can thanks a lot!

HTTP status error

HTTP status error

I am using Eclipse Kepler wit Tom cat 7.0.12. I created a dynamic web
project consisting of a jsp named as index.jsp and it was working fine
before i renamed the index.jsp as oldindex.jsp and created one another
index.jsp. however since than I am in problem. each time i run my web
application within the eclipse using run at server i received following
error: HTTP status 404 /(name of folder of my created web project) type
status report description the requested resource (/my web project folder
name) is not available. I have created a new project from scratch even
than it returns same. than i delete the tom server and created new server
within the eclipse and created a new web dynamic project. however it did
n't work either. I can see the inside the eclipse the tomcat server is
running. any help as i have spent two days without any luck.

Tuesday, 1 October 2013

horizontal layout Website like Myspace.com

horizontal layout Website like Myspace.com

I want to develop a horizontal layout Website like Myspace.com but for
each picture when you click on it, it does not go to another page but goes
to another section of this page ( it must be one page website)I need
advise for hoe i can handle that with css Html and jQuery ? I tried this
code :
<div id="menu">
<ul>
<li><a href="#home">Home</a>
</li>
<li><a href="#box1">History</a>
</li>
<li><a href="#box2">gallery</a>
</li>
</ul>
</div>
<div id="container">
<div id="header">
<h1>Burnham Beeches</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut
eget eros libero. Fusce tempus quam sit amet erat mollis a
fermentum nibh imperdiet. Fusce iaculis sapien in turpis aliquet
porta. Donec tincidunt gravida tortor, vel dignissim augue
convallis sit amet. Aliquam auctor ornare accumsan.</p>
</div>
<div id="box1" class="box">
<h2><a name="box1">History</a></h2>
<img src="images/burnham-beeches-history-fullpage.jpg" />
</div>
<div id="box2" class="box">
<h2><a name="box2">Second Box</a></h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut
eget eros libero. Fusce tempus quam sit amet erat mollis a
fermentum nibh imperdiet. Fusce iaculis sapien in turpis aliquet
porta. Donec tincidunt gravida tortor, vel dignissim augue
convallis sit amet. Aliquam auctor ornare accumsan. Cras convallis
elit tincidunt arcu semper egestas. Mauris interdum fringilla
nisi. Cras a dapibus lectus. Praesent blandit ullamcorper ornare.
Nam hendrerit sollicitudin urna non ultricies. Phasellus
condimentum auctor risus, at accumsan tellus tempor vel. Nunc
mattis eleifend dolor at adipiscing.</p>
</div>
</div>
but ineed to have pictures not text

Injecting html snippet with JQuery into existing html page

Injecting html snippet with JQuery into existing html page

I want to inject certain html snippet with JQuery into existing html page.
Existing snippet:
<table class="course hoverHighlight">
<tbody>...</tbody>
...
</table>
I want to inject:
<thead>
<tr>
<th class="title">Course</th>
<th class="author">Author</th>
<th class="level">Level</th>
<th class="rating">Rating</th>
<th class="duration">Duration</th>
<th class="releaseDate">Released</th>
</tr>
</thead>
before tbody tag.
<table class="course hoverHighlight">
<thead>...</thead>
<tbody>...</tbody>
</table>
I have tried this code but it didn`t work:
function() {
var theadInjection= $("<thead>
<tr>
<th class="title">course</th>
<th class="author">author</th>
<th class="level">level</th>
<th class="rating">rating</th>
<th class="duration">duration</th>
<th class="releasedate">released</th>
</tr>
</thead>");
$( '.course' ).prepend(theadInjection);
}
Simple injection like this one did work:
function() {
var theadInjection= $("<thead></thead>");
$( '.course' ).prepend(theadInjection);
Thanks.

Passing PCI Scan on apache 2.2.22

Passing PCI Scan on apache 2.2.22

We are on Ubuntu 12.04 and apache 2.2.2 version. We had PCI scan done on
our site and 2 vulnerabilities came out that we can not get under control.
First one is BEAST attack and other one SSL RC4 Cipher Suites Supported.
So far I have tried following that looks promising. I tried with few more
changes after searching for help, but those changes in turn started
breaking browsers and were discarded.
SSLProtocol -SSLv2 -TLSv1 +SSLv3
SSLHonorCipherOrder On
SSLCipherSuite
ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-RC4-SHA:ECDHE-RSA-RC4-SHA:ECDH-ECDSA-RC4-SHA:ECDH-RSA-RC4-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:!MD5:!aNULL:!EDH
SSLCompression off
or
SSLProtocol ALL -SSLv2
SSLHonorCipherOrder On
SSLCipherSuite
ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AES:RSA+3DES:!ADH:!AECDH:!MD5:!DSS
SSLCompression off
Based on scan results on ssllabs, I am able to get only one of the
vulnerability mitigated. What changes I need to do so that both
vulnerabilities are addressed and does support current version of
browsers?