• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
maggie karve
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Import the classes that are missing.

If you're using an IDE this can be done automatically.
 
maggie karve
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Skipping Struts 1 unless you have a good reason to learn it.
 
maggie karve
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you mean its ok..if i skip struts 1 and directly start with struts 2....thanks...
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes; they're complete different.
 
vijin das
Ranch Hand
Posts: 129
Firefox Browser Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FIRST LEARN SERVLETS THEN JSP THEN TRY TO UNDERSTAND MVC ARCHITECTURE .....THEN TRY TO LEARN ANY MVC FRAMEWORK ...
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please KeepItDown! :)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic