Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML
 
 
Hot Web Programming Job

 

Tutorial Categories: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML


 

Java Tutorials

Core Java
JSP
Servlet
JDBC
Hibernate
Struts 1
Struts 2
JSF
Spring
J2EE
J2ME
Web Services
Ajax
Dojo
MySQL
Latest Comments
Null pointer excep
swap program faile
hi.........
very good
navigaton mobile
  All Comments...
 

 

 
Struts Tutorials
*Stuts TOC
*Apache Struts Introduction
* Struts Controller
* Struts Action Class
* Struts ActionFrom Class
* Using Struts HTML Tags
*Struts Validator Framework    
*Client Side Address Validation    
*Struts Tiles
*tiles-defs.xml
*Struts DynaActionForm
*Struts File Upload
*Struts DataSource
*AGGREGATING ACTIONS
*Internationalization
Struts Resources
*Struts Books
*Struts Articles
*Struts Frameworks
*Struts IDE
*Struts Alternative
*Struts Links
*Struts Presentations
*Struts Projects
*Struts Software
*Struts Reference
*Struts Resources
*Other Struts Tutorial
Visit Forum! Post Questions!
Jobs At RoseIndia.net!

Have tutorials?
Add your tutorial to our Java Resource and get tons of hits.

We offer free hosting for your tutorials. and exposure for thousands of readers. drop a mail
roseindia_net@yahoo.com
 
   

 
Join For Newsletter

Powered by groups.yahoo.com
Visit Group! Post Questions!

Testing Struts Application

                         

It will be noticed that there are a lot of 'system.out.println's in the action class code.Intentionally so! The step by step progress gets printed in the Tomcat console and is very instructive. When trouble occurs, it aids in diagnosis greatly.It also gives us a clear understanding.

------------------------------------------

But, understanding the code is one thing ( and the easier thing at that) and actually executing the program ,is quite a different thing altogether! We must do each step with maximum care, to avoid a lot of problems.

------------------------------------------

We begin by creating a folder( say)

        g:\examplestruts>

Our proposed package name is demo1;

So create a subfolder  named 'demo1'.

cd to g:\examplestruts\demo1

--

 Create the following six files in demo1 folder.

     i) query.jsp

     ii) QueryForm.java

     iii) QueryAction.java

     iv) sqlbean.java

     v)  resultbean.java

     vi) result.jsp

------------------------------------

We cannot compile QueryForm.java & QueryAction.java , unless we first instal Struts in our system.

---------------------------------

How do we instal Struts in our system?

-----------------

steps.

-------------

1)transfer jakarta-struts1.1 zip file from DeveloperIQ CD  to g:drive.

2)unzip it into c:\unzipped.

3)It got unzipped   as jakarta-struts1.1 folder.

----------------------------------------------

We get three folders and 3 files.

4)  The 3 folders are     a)contrib

                          b) lib

                         c) webapps

                               ============

  The 3 files are:

 5)                   a) readme.txt

                     b) license.txt

                     c) instal.txt

-----------------------------------------------

6) open webapps folder.

7) we will find the following   war files there.( web-application-archives)

          a)struts-blank

          b)struts-documentation

          c) struts-example

          d) struts-exercise-taglib

          e) struts-template

          f) struts-upload

          g) struts-validator

----------------------------------------------

8) copy struts-blank.war  into:

    g:\tomcat41\webapps     folder.

----------------------------------------------

9) In a   DOS window, cd to g:\tomcat41\bin

10) >set JAVA_HOME=D:\JDK1.4

11) startup

-----

12) tomcat server gets started .

13) Now in another dos window , check up that struts-blank.war has automatically  expanded by the server and we get a folder named

struts-blank.

 14) If you expand struts-blank folder, there are 3 subfolders there.

          i) META-INF

         ii) WEB-INF

        iii) pages

    There is also an index.jsp

-----------------------------------------------

15) start the browser and type the url as :

 http://localhost:8080/struts-blank/index.jsp

----------------------------------------------

16) You will get the corresponding display as follows:

 Welcome!

To get started on your own application, copy the struts-blank.war to a new WAR file using the name for your application. Place it in your container's "webapp" folder (or equivalent), and let your container auto-deploy the application. Edit the skeleton configuration files as needed, restart your container, and you are on your way! (You can find the application.properties file with this message in the /WEB-INF/src/java/resources folder

-----------------------------------------------

  Thus, we have correctly installed struts in our tomcat server.

===========================================

Inside the WEB-INF folder, we have the following subfolders and files.

sub-folders

i)classes

ii) lib

iii) src

-----------------------

files

===

tld files  ( 6 files)

=====

    1)  struts-bean.tld

     2) struts-html.tld

     3) struts-logic.tld

     4) struts-template.tld

     5) struts-tiles.tld

     6) struts-nested.tld

-------------------

xml files  ( 5 files).

=====

   i) web.xml

   ii) struts-config.xml

  iii) tiles-defs.xml

  iv) validation.xml

  v) validator-rules.xml

============================================

There are a number of jar files available in lib folder.

i) commons-beanutils.jar

ii) commons-collections.jar

iii) commons-digester.jar

iv) commons-fileupload.jar

v) commons-lang.jar

vi) commons-logging.jar

vii) commons-validator.jar

viii) jakarta-oro.jar

ix) struts.jar

-------------------------------------

All this is just for information.

===========================================

When we want to build our own application, we first copy  struts-blank folder in the webapps  folder of tomcat & Rename the folder .(say) sam. And restart the Tomcat server.

struts.jar was copied to c:\quick folder for easily remembering the classpath.

==============================================Now, we are ready to begin compiling.

We are now in g:\examplestruts\demo1

>set path=c:\windows\command;d:\jdk1.4\bin

>set classpath=g:\examplestruts;c:\quick\struts.jar;d:\tomcat41\common\lib\servlet.jar

..demo1>javac QueryForm.java

..demo1>javac sqlbean.java

..demo1>javac resultbean.java

..demo1>javac QueryAction.java

( if we compile the files one

after the other, in this sequence, we will be able to compile easily.

After compiling, copy all the class files in this folder to:

g:\tomcat41\webapps\sam\WEB-INF\classes\demo1

 

copy query.jsp & result.jsp to:

'g:\tomcat41\webapps\sam'

now in another dos window, cd to:

g:\tomcat41\webapps\

sam\WEB-INF\struts-config.xml

edit the struts-config.xml as follows:

==========================================

<?xml version="1.0" encoding="ISO-8859-1" ?>

 <!DOCTYPE struts-config PUBLIC

  "-//Apache Software Foundation//      DTD Struts Configuration 1.1//EN"   "http://jakarta.apache.org/struts/ dtds/struts-config_1_1.dtd">

 <struts-config>

   <form-beans>

    <form-bean       

            name="queryForm" 

            type="demo1.QueryForm"   />

   </form-beans>  

     <action-mappings>

        <action  

                  path="/Query"

                  type="demo1.QueryAction"

                  name="queryForm"

                  scope="session"

                  input="/query.jsp" >

            <forward    name="success" path="/result.jsp" />

           <forward    name="failure" path="/query.jsp" />

       </action>

     </action-mappings>

 </struts-config>

==============================================

--

After all these steps, restart the Tomcat server, so that the settings become effective.

Type the URL in browser as:

'http://localhost:8080/sam/query.jsp'

You should get a form with orange background, etc.

 If we type the password as 'ADMINISTRATOR' and the sql as 'select * from table1', we will get the query result. ( Ofcourse, the example presumes the usual creation of a simple  Access database named 'dbdemo' with just table1 having two fields ( name, place) and registering it  in ODBC.

 If the password is wrong, the page appears to be not responding  just showing whatever we typed.

So, our adventure  with Struts has had a happy ending.

 If we get, this far, we can and  must build up further

by   in-depth study of   books.& articles.

In  the forthcoming instalments, we will see advanced Struts topics like :

                    DynaForm

                    Validator   Framework

                    Tiles

                     RequestProcessor

                     Scaffold

                     Struts-Tags

                ------------------------

This tutorial cannot  be a substitute  for hundreds of articles and dozens of books on Struts .It is but a simple introduction .

Respectful  Acknowledgements to:

1)  'Struts your Applications'

         by

     Piyush  SriVasthava

     ( DeveloperIQ---November-2002)

2) 'Understanding Struts Framework'

         by

     Manoj Kothale

   ( DeveloperIQ.....August-2003)

==================================

Suggested Reading:

   1) Struts in Action .

         by

       Ted Husted

      ( Manning press/ DreamTech publication)

   2) Mastering Jakarata Struts

         by

       James Goodwill

     (Wiley/DreamTexh)

   3) Professional Struts Applications

       by

       John Carnell

     ( Wrox )

==============================================

                         

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

11 comments so far (
post your own) View All Comments Latest 10 Comments:

Hi,
The struts tutorial was very helpful for me to learn.
Thank you Rose India!!!!!

Suganthi.

Posted by Suganthi on Friday, 09.19.08 @ 17:54pm | #80540

Hi Sanjay,

I have got the solution,

just remove

type="demo1.QueryForm" name="queryForm"

from <html:form ...
ie your line will be only as follows
<html:form action="/Query.do" >

save jsp and reload in browser,

Regards,
Milind

Posted by Milind on Sunday, 05.25.08 @ 00:52am | #60927

Even i'm getting the same error,
got any solution for this?

Posted by Milind on Sunday, 05.25.08 @ 00:32am | #60925

From where I will get struts-blank.war file which is compatible to jdk1.4

Posted by shipra on Monday, 12.24.07 @ 18:15pm | #43596

Good
send me if any example in struct using eclipse5.1

Posted by selestin on Tuesday, 11.6.07 @ 13:00pm | #35897

i did not get proper result of this demo
i get this exception
query.jsp(6,0) Unable to find setter method for attribute: name
plz tell me what is wrong with me

Posted by rajeev on Wednesday, 04.18.07 @ 20:06pm | #14507

Hi
When i m trying to access http://localhost:8080/sam/query.jsp, I m getting following exceptional error, can any one help me plz

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: /query.jsp(5,0) Attribute name invalid according to the specified TLD
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:94)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:428)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:186)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:498)
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:707)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:1028)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:1070)
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:1076)
at org.apache.jasper.compiler.Node$Root.accept(Node.java:232)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:1028)
at org.apache.jasper.compiler.Validator.validate(Validator.java:607)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:226)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:351)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:474)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:184)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
at java.lang.Thread.run(Thread.java:595)

Posted by sanjay kumar on Wednesday, 03.7.07 @ 17:18pm | #10998

nice material...

i followed the instructions and deployed application.
But when I tried to access query.jsp, tomcat is throwing following exception.....

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: File "/WEB-INF/struts-html.tld" not found
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

org.apache.jasper.JasperException: File "/WEB-INF/struts-html.tld" not found
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:50)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:114)
org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:159)
org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:423)
org.apache.jasper.compiler.Parser.parseDirective(Parser.java:492)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1552)
org.apache.jasper.compiler.Parser.parse(Parser.java:126)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:211)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:155)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.14 logs.


Thanks,
Sreedhar

Posted by sreedhar on Thursday, 02.8.07 @ 16:42pm | #6797

i did the same as u said in the document.Finally i am getting the following error description can u plz resolve it

The server encountered an internal error () that prevented it from fulfilling this request.

Posted by amaran on Wednesday, 01.10.07 @ 14:25pm | #3117

Actually i compiled the Class files and placed as it said before...

After made changes in web-inf when i restart the tomcat server...

i am unable to get any page

the error what i am getting was...

-------------------------------------
HTTP Status 404 - /Arun/query.jsp
-------------------------------------
type Status report

message /Arun/query.jsp

description The requested resource (/Arun/query.jsp) is not available.

Posted by Arunkumar on Wednesday, 12.20.06 @ 16:42pm | #1344

  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification

Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2007. All rights reserved.