aspose file tools*
The moose likes Struts and the fly likes which are the main packages to import while writing a strut app? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "which are the main packages to import while writing a strut app?" Watch "which are the main packages to import while writing a strut app?" New topic
Author

which are the main packages to import while writing a strut app?

maggie karve
Ranch Hand

Joined: Dec 29, 2009
Posts: 187
Hi,
i am a newbie in struts ,was trying to execute a HelloWorld example using struts ,i have copied exactly the same example as it is,but it doent have the classes which are to be imported while executing the application..

i wrote a class



kindly tell me what file am i missing and what do i do to import these files
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Import the classes that are missing.

If you're using an IDE this can be done automatically.
maggie karve
Ranch Hand

Joined: Dec 29, 2009
Posts: 187
i am trying to download struts from apache..
i am having all zip files...shall i download all the files and where should i locate them??
i downloaded Struts 2.1.8.1 release...
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Your code, however, is written for Struts 1--you should first decide which to use.

If you're asking about the general layout of a Java web app I'd recommend a tutorial or two first--do not start with Struts.
Jaya Krishna
Greenhorn

Joined: Jun 13, 2010
Posts: 8
Try this once.
include the following packages in your action class.

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
maggie karve
Ranch Hand

Joined: Dec 29, 2009
Posts: 187
i tried executing the same program in IDE ,even after importing the packages i am getting compiler error on....

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

which jar files are required as executables for running this application???

when i say
public class HelloWorldAction extends org.apache.struts.action.Action

it give complier error on

org.apache.struts.action.Action

what am i missing??

thanks...
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

The Struts 1 jars.

I'll repeat my question: are you trying to write a Struts 1 app, or a Struts 2 app? It makes a pretty big difference. Your code is for Struts 1.
maggie karve
Ranch Hand

Joined: Dec 29, 2009
Posts: 187
my problem is resolved i used one jar file for compiling called struts-core-1.3.10.jar and it compiled fine.........
now i have another doubt in the same application..i have written 2 classes one is dependent on another...
first is ....

second is

when i compile both the servlets HelloWorldActionForm.java compiles well but HelloWorldAction gives complier error as follows

HelloWorldAction.java:4: cannot find symbol
symbol : class HelloWorldActionForm
location: package myServlets
import myServlets.HelloWorldActionForm;
^
HelloWorldAction.java:19: cannot find symbol
symbol : class HelloWorldActionForm
location: class myServlets.HelloWorldAction
HelloWorldActionForm helloWorldForm = (HelloWorldActionForm) form;
^
HelloWorldAction.java:19: cannot find symbol
symbol : class HelloWorldActionForm
location: class myServlets.HelloWorldAction
HelloWorldActionForm helloWorldForm = (HelloWorldActionForm) form;
^
3 errors

though i have written line 1..
what is my mistake....kindly reply..


thanks in advance...
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Looks like a classpath issue; your packages need to be on the classpath, just like the Struts 1 jar(s).

So you're actually trying to learn Struts 1? Is there a reason?
maggie karve
Ranch Hand

Joined: Dec 29, 2009
Posts: 187
i don know anything about struts...hence i started with struts one...then will go on with struts 2...what do you suggest?

thanks...
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Skipping Struts 1 unless you have a good reason to learn it.
maggie karve
Ranch Hand

Joined: Dec 29, 2009
Posts: 187
you mean its ok..if i skip struts 1 and directly start with struts 2....thanks...
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Yes; they're complete different.
vijin das
Ranch Hand

Joined: Jun 07, 2010
Posts: 129

FIRST LEARN SERVLETS THEN JSP THEN TRY TO UNDERSTAND MVC ARCHITECTURE .....THEN TRY TO LEARN ANY MVC FRAMEWORK ...


VIJINDAS
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please KeepItDown! :)
 
 
subject: which are the main packages to import while writing a strut app?