Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link

Edwin Stephens

Greenhorn
+ Follow
since Dec 30, 2008
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 Edwin Stephens

Hi Michael,

Here is a maven tutorial website that might help you. It describes setting up maven and how you can use maven with Eclipse via command-line maven commands (which are run as Eclipse External Tool Configurations).

http://www.avajava.com/tutorials/categories/maven

Hope that helps,
Edwin


12 years ago
Hi Antonio,

If you have a 3rd-party jar file in your original project that has no version number on it, you can check if it already exists in the maven central repository using this tool:

http://www.jarvana.com/jarvana/digest-check

You upload the jar file and it generates md5 and sha1 checksums for the file and then checks to see if these checksums exist in the central repository. If the md5 or sha1 checksum is found, the tool will give you the dependency information (groupId, artifactId, version) for the jar file.

Hope that helps,
Edwin
13 years ago
Hello RaviNada,

If you are using Tomcat, you can accomplish this via the Invoker Servlet (org.apache.catalina.servlets.InvokerServlet) in Tomcat's web.xml file. It allows you to execute servlet classes without needing to map them in web.xml.

However, in general this is not a good practice, since servlet mappings function to prevent users from accessing resources that they shouldn't have access to. Also, hundreds of servlets seems excessive! You may want to consider rolling functionality into fewer servlets, and when you do this, mapping becomes much more manageable.

Edwin

13 years ago
Hello Vinoth,

You can also use the ImageIO class to read the jpeg image file and write it to the response output stream, like this:



This technique is detailed here:
http://www.avajava.com/tutorials/lessons/how-do-i-return-an-image-from-a-servlet-using-imageio.html

Hope that helps,
Edwin
13 years ago
Hi Susan,

You might want to try making this modification and then restart Apache and see if it helps.



Good luck,
Edwin
13 years ago
Hi Susan,

Are you running your servlet/jsp container behind an apache web server? If so, the apache web server might be allowing access to files inside of WEB-INF that normally shouldn't be accessed. If this is the case, you can prevent this from happening by modifying the access permissions in httpd.conf or .htaccess.

Edwin
13 years ago

I have found Apache's Continuum to be a very easy to use open source solution.
http://continuum.apache.org/
13 years ago
Hi Nick,

If you are new to writing software, the combination of Notepad and compiling Java at the command prompt can be a decent way to start. However, after learning the basics of writing a few java classes and compiling them manually, I would highly recommend taking the plunge into Eclipse. You can literally write software probably ten times faster using an IDE like Eclipse versus the command prompt. As an example of how cool Eclipse is, you might want to try copy/pasting a Java class from Notepad into Eclipse. You will see that all your code gets color-coded. Also, you can hit Control-Shift-F, and your code will automatically get formatted. Also, you can use things like hitting Control-Space in places in your code, and Eclipse will automatically give you code-completion options.

Edwin
13 years ago
Hi Sachin,

Yes, you can use the codehaus jspc-maven-plugin to precompile your JSPs.

A couple examples of using jspc-maven-plugin can be found at:
http://www.avajava.com/tutorials/lessons/how-do-i-precompile-my-jsps.html
http://www.avajava.com/tutorials/lessons/how-do-i-precompile-my-jstl-jsps.html

Hope that helps,
Edwin
13 years ago
You might want to investigate using the Apache Commons Configuration library at http://commons.apache.org/configuration/index.html. It allows you to deal with configuration data using a variety of sources such as properties files or databases.

In a web app, loading the configuration data at startup can be done both with a ServletContextListener and the init() method of a servlet. Although I've heard the ServletContextListener way is more proper, I tend to use a servlet's init() method, since I can control when the servlet is loaded (via load-on-startup) in relation to other servlets, so that config data can be initialized before other servlets need that data.

Another thing to be wary about is if you're working in a multi-app server environment. If you need to refresh your data, make sure you have a mechanism that can do so across app servers, since you would need to perform the refresh across JVMs.

Edwin
13 years ago
Hi Ravii,

The iText library (homepage http://www.lowagie.com/iText/) is a great library for generating PDFs via Java.

An example of using iText to generate a PDF file can be found at http://www.avajava.com/tutorials/lessons/how-do-i-write-to-a-pdf-file-using-itext.html.

An example of serving up a PDF file from a servlet can be found at http://www.avajava.com/tutorials/lessons/how-do-i-serve-up-a-pdf-from-a-servlet.html.

If you want to generate PDF content to be served up directly through a servlet with no intermediary file in the file system, this can usually be accomplished by writing the generated PDF content to the output stream of the servlet directly rather than writing to a file output stream. Elliotte Rusty Harold's Java I/O book is a great resource for understanding streams.

Hope that helps,
Edwin
Hi Ronnie,

Perhaps this code will help you execute maven via the runtime exec? It calls the mvn.bat file in maven's bin directory (this is for execution on Windows), calling the test phase of the maven lifecycle. (Note that maven's bin directory needs to be on your path.) It executes on the "myproject2" project, which is located at C:\myworkspace\myproject2.





Hope that helps,
Edwin
13 years ago
Hi Ramya,

For stopping, starting, undeploying, and deploying to Tomcat via Ant, you might want to consider trying out the following Ant tasks in the catalina-ant.jar file:


A tutorial showing how to build a war file and deploy to Tomcat using the Ant DeployTask can be found here:
http://www.avajava.com/tutorials/lessons/how-do-i-deploy-to-tomcat-using-ant.html

Hope that helps,
Edwin
13 years ago
Hi,

I see two potential possibilities.

One, you may need to have the maven bin directory on your path. On Windows, typically, I will create a System Variable called M2_HOME and set it to maven's home directory, such as C:\dev\apache-maven-2.0.9. Then, I update my System Path to include %M2_HOME%\bin; so that maven's bin directory is on the System Path.

Another possibility is how you are calling maven. If calling "mvn" isn't working for you, you might want to try substituting "mvn.bat" instead and see if that works.

Hope that helps,
Edwin
13 years ago
Hi,

I think the "Maven 2 Exec Plugin" offers the capabilities that you are looking for. In summary, "The plugin provides 2 goals to make execution of system and Java programs."

The plugin's two goals are:
exec::exec - execute programs and Java programs in a separate process
exec::java - execute Java programs in the same VM

The project's homepage and documentation can be found at:
http://mojo.codehaus.org/exec-maven-plugin/

The plugin exists in the central maven repository. Links to the versions of the plugin in the central repo (including dependency information) can be found here:
http://www.jarvana.com/jarvana/search?search_type=project&project=exec-maven-plugin

Hope that helps,
Edwin
13 years ago