Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.

Harry Henriques

Ranch Hand
+ Follow
since Jun 17, 2009
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Harry Henriques

Hello,

Please examine the code snippet below. I don't understand why K&B say that "reference variables must be initialized before the constructor completes." The code below compiles and runs just fine.

Thanks,

K&B Two Minute Drill Chapter 1 wrote:final variables have the following properties:
final variables cannot be reinitialized once assigned a value.
final reference variables cannot refer to a different object once the object has been assigned to the final variable.
final reference variables must be initialized before the constructor completes.



C:\temp>cat Final.java



C:\temp>vi Final.java

C:\temp>gvim.exe Final.java

C:\temp>javac Final.java

C:\temp>java Final
thisReference says hello
10
Hello,

I'm trying to solve a fairly simple problem using Struts 1.3.10, and I just want to confirm that my understanding for usage of the bean:define tag is correct.

Struts JavaDoc wrote:
id = Specifies the name of the scripting variable (and associated page scope attribute) that will be made available with the value of the specified property.
name = Specifies the attribute name of the bean whose property is accessed to define a new page scope attribute (if property is also specified) or the attribute name of the bean that is duplicated with the new reference created by this tag (if property is not also specified). This attribute is required unless you specify a value attribute or nested body content.



My questions are the following? In the example on the Subject line, is an Attribute named "layoutName" created in page-scope, and is "layout-name" only another reference to "layoutName"?

Is "layout-name" strictly a duplicate reference to the created Attribute "layoutName", or does "layoutName" also assume the dereferenced value of "layout-name"?

Does the Attribute "layoutName" have the same initial value as "layout-name"?

Thanks,
Harry
6 years ago
Hello,

This example is from K + B SCJP Study Guide (Java 6) pp752-753

I don't understand what this example is trying to demonstrate.

I believe that the following is true about the code snippet below:

(1) There is only one Calculator instance, but there are multiple references to the same Calculator instance.
(2) All three run() methods in the three instances of the Reader class synchronize on the same Calculator object.
(3) The main() method in the Reader class creates three Reader threads, starts all three threads, each thread enters the synchonized(c) block and invokes wait() on the same Calculator object.
(4) All three Reader threads enter the wait state virtually immediately after being started.
(5) The Calculator thread only runs once.
(6) All three Reader threads print out the same result, one after the other, after they have been notified to enter Runnable.

My question is this: Do I understand or do I not understand how this code snippet works?

It seems overly complex, and seems to only printout the same result three times in succession.


hph@www:~$ javac Reader.java
hph@www:~$ java Reader
Total is: 4950
Total is: 4950
Total is: 4950
hph@www:~$




Hello,

I have two ActionClasses and I have two ActionForms in my Struts application. I am getting the following error message in the stack trace. There are two form-beans: logonForm and addCourseForm. The property that is not being satisfied is not in LogonForm at all, but is in AddCourseForm. Do you see what I'm doing wrong? I've looked at this for several hours.

javax.servlet.jsp.JspException: No getter method for property: "courseId" of bean: "examples.LogonForm"








web.xml



struts-config.xml

7 years ago

Programming Jakarta Struts by Chuck Cavaness wrote:

If you use only a single Struts configuration file, you will have only a single application. This is known as the default application. To make processing requests for the default application and the application modules simple and consistent, the default application is treated as just another application module. Therefore, any requests that don't contain an application suffix will be routed and handled by the default application.



This is a general note in the referenced text. I don't understand this note. I googled "application suffix", and I wasn't able to find a useful explanation. Can you help me?

Thanks,
Harry
7 years ago
Hi Bear,

I'm working through the examples in Head First Servlets and JSPs. This is an example directly out of the textbook. I have to start somewhere, so I'm starting with the fundamentals.

Thanks,
Harry
7 years ago
JSP
Hi All -

[PROBLEM SOLVED] Below is a good example of how to use the jsp:useBean standard action.

Thanks,
Harry









The employee's name is Fred
The friends who share your hobby of horse skiing are:
Fred
Pradeep
Philippe
7 years ago
JSP
Hello,

I am now able to forward an HTTP/1.1 request from Apache 2.2.14 to Tomcat 7.014 on Ubuntu 10.04 LTS (32-bit) in a VirtualBox 4.0.6r71416 on top of Windows 7 (64-bit):



The DocumentRoot for the default VirtualHost in apache2 is /var/www. In this folder, /var/www/Beer-v1/form.html is the only file (a static HTML page).

It is unnecessary to have WEB-INF/web.xml on the apache2 side.

$TOMCAT_HOME/webapps/Beer-v1/WEB-INF/web.xml is all that is needed to map SelectBeer.do to $TOMCAT_HOME/webapps/Beer-v1/WEB-INF/classes/com/example/web/BeerSelect.class

The following request is forwarded by the mod_jk.so to the tomcat-connector at port 8009 specified in $TOMCAT_HOME/conf/server.xml



I didn't modify $TOMCAT_HOME/conf/server.xml at all.

On the apache2 side, the workers.properties file specifies that worker.ajp13_worker.port=8009

mod_jk.so (1.2.28) is packaged with Apache2.2.14, and is in the /usr/lib/apache2/modules/mod_jk.so folder. I was able to successfully use this binary file without generating my own copy.

I was unable to auto-generate the mod_jk.conf file using the "-jkconf" option at Tomcat 7.0.14 startup. I don't think that it is possible with this version of Tomcat.

I did download tomcat-connectors-1.2.31-src.tar.gz from the tomcat-connectors website. This tarball has a file called httpd-jk.conf that is useful when generating your own mod_jk.conf

apache2 has another example /usr/share/doc/libapache2-mod-jk/httpd_example_apache2.conf

I used both of these examples to implement mod_jk.conf. I put the finished version in /etc/apache2/mods-enabled/mod_jk.conf. This file is Include in /etc/apache2/apache2.conf.

I removed "LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so" from mod_jk.conf. This line is already included in /etc/apache2/mods-enabled/jk.load.

I didn't "Include /usr/lib/apache2/modules/mod_jk.so" in httpd.conf.

I used the apache2 example in /etc/libapache2-mod-jk/workers.properties file. I copied, modified, and saved this file right in this folder.

In a fresh install of apache2, the /etc/apache2/httpd.conf file is empty. I put the following code snippet in this file. This file is Include in /etc/apache2/apache.conf.



There is an entry in /etc/hosts, i.e. 127.0.0.1 localhost.localdomain localhost

ajp13_worker was created in the workers.properties file.

I created a tomcat user in Ubuntu and in the $TOMCAT_HOME directory I executed the following command: sudo chown -R tomcat:tomcat *

This will only work after you create a tomcat user.

I also did this in $CATALINA_HOME.

A useful link is the following: http://www.linuxjournal.com/article/8561

Regards,
Harry Henriques
7 years ago
Hello,

I guess it is version 1.2.28 of mod_jk.so that is in the /usr/lib/apache2/modules directory.
The current released version is 1.2.31 on the tomcat-connectors website, dated Nov 2010.

This is a snippet from the /var/log/apache2/mod_jk.log
[Fri Jul 01 11:56:15.495 2011] [1220:3075155712] [info] init_jk::mod_jk.c (3183): mod_jk/1.2.28 initialized

Harry
7 years ago
Hello,

The http://tomcat.apache.org/connectors-doc/miscellaneous/faq.html says that mod_jk.so "works well with Apache 2.2".

It says that you need to download the binary module compiled for version 2.2. On Ubuntu 10.04 (32-bit) in the /usr/lib/apache2/modules directory, there are (3) important files, i.e. mod_proxy_ajp.so, mod_proxy_balancer.so, and mod_jk.so. Is this the connector that I need to use with Apache 2.2.14 ? If it is, I can't seem to get the installation to work. I can't communicate between Apache and Tomcat.

What do you think?

Harry Henriques
7 years ago
Hello,

I'm not really sure if I'm making any progress. I copied my webapplication from /var/lib/tomcat7/webapps to /var/www. I can launch the application from either Apache2.2.14 or from Tomcat7.0.14 with either http://localhost:80/Beer-v1/form.html or http://localhost:8080/Beer-v1/form.html, respectively.

In /var/www/Beer-v1/WEB-INF, I have the web.xml file that defines the servlet:



When I launch the webapplication from Apache2.2.14, I get the following error message:



I have setup httpd.conf
I have setup workers.properties with a worker called ajp13_worker on port 8009
I am using mod_jk.so that was included with apache2 on Ubuntu.

I'm not exactly sure what is going wrong? Any ideas?

Thanks,
Harry Henriques
7 years ago
Hello,

Thanks for looking at this thread.

I am not able to forward requests from Apache2.2.14 to Tomcat7.0.14 using the following browser address:



I am able to invoke the servlet directly from the Tomcat7.0.14 container using the following browser address:



$CATALINA_HOME is /usr/share/tomcat7
$CATALINA_BASE is /var/lib/tomcat7



I have been working on this problem for hours, and I haven't been able to access Tomcat 7 from Apache 2.

Do you have any ideas where I might look to correct this problem?

Thanks,
Harry
7 years ago
[SOLVED]

Setup Eclipse and Tomcat to play nice together

This is nice to do, but not necessarily the solution to my problem.

CHANGE THE BUILD PATH IN ECLIPSE HELIOS

1. Right click on the Project and choose Properties

2. Choose Java Build Path in the Left Panel. Click the Source Tab in the Right Panel.

3. Change the Default Output Folder in the textbox at the bottom of the page: YourProjectName/WebContent/WEB-INF/classes

4. Click OK.

THIS IS WHAT SOLVED MY PROBLEM - Configure Tomcat 7

1. Open the Server View, if it's not displayed already, then Window -> Show View -> Other -> Server -> Servers

2. In Server View, right click on: Tomcat v7.0 at localhost [Stopped]

3. Choose Add and Remove ... from ListView

4. Choose the project that was created (i.e. HearingImpaired) from Available projects and ADD the project to Configured projects. Click OK.

5. Restart/Start Tomcat 7 container.

STEP 4 OF PART 2 DID THE TRICK !
Here is the rest of the code: