File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Learning Struts before Servlets and JSP (follow-on to Struts Survey post) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Learning Struts before Servlets and JSP (follow-on to Struts Survey post)" Watch "Learning Struts before Servlets and JSP (follow-on to Struts Survey post)" New topic
Author

Learning Struts before Servlets and JSP (follow-on to Struts Survey post)

Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
I've been hoping to try and generate some good discussion in this forum. I had posted an informal survey in another thread trying to get an idea about people's Servlet and JSP knowledge level when they picked up Struts. I got some good answers, but because a lot of the people I was hoping would respond didn't, it didn't really make the point I was hoping to.

Having moderated this forum for awhile, I have made the observation that a lot of people are jumping into Struts without having what I feel is a necessary background in Servlets and JSP. I suspect this is mainly the fault of employers who don't want to spend the time properly developing employees skill sets, but rather just want to get them producing something even if they aren't gaining the fundamentals needed to be as successful as they could be. Aside from employers pressuring developers, I also get the impression that there also exists a subset of people who just want to get Struts added to their resume and are looking to run before they can walk.

It's my belief that an understanding of any web framework, Struts being one of many, is absolutely predicated on a thorough understanding of Servlets and JSP. Servlets and JSP are the foundations on which just about all of these web app frameworks are built, and it's just not reasonable to assume that someone can fully grasp the framework if they don't grasp the foundations.

To re-iterate, in the other thread I asked people which category they fell into:

1. Prior to learning Struts, I was well versed in Servlets and JSP, and had professional experience developing applications using Servlets and JSP.

2. Prior to learning Struts, I had read books about Servlets and JSP (or taken the SCWCD exam), but had no professional experience developing applications using JSP and Servlets.

3. Prior to learning Struts, I had little knowledge concerning Servlets and JSP.


I think a couple quotes from the other thread illustrated the point I was driving at well:

Originally posted by Gregg Bolinger...
3 then 2. I started learning struts then realized I needed more experience with Servlets and JSP. Stopped Struts, got versed in Servlets/JSP then came back to Struts.


Originally posted by Marc Peabody...
#2 with failure, then #1 with success.

I tried learning Struts after getting SCWCD when I had very little working experience. I didn't understand it.

I tried learning it again a year later after gaining more professional experience and it made more sense then.


Originally posted by Tim West...
3...I learned Struts, JSP and Servlets all at the same time. I reckon you end up blurring the concepts of each pretty heavily in learning this way - I'm going to go over Servlets and JSP separately as soon as I find a spare few hours

Learning all 3 at the same time is like learning the 'practice' without the 'theory' in any area...I can make stuff work, but I don't really know how it all ties together. Not a nice feeling, I reckon.


So a few questions for people...

- If you are learning Struts but don't have practical experience in JSP and Servlets (that is, you fall into category 3 of the other thread), why?

- If you are in a position to influence younger developers in your organization, is there anything you do to encourage them to learn the fundamentals before jumping into a framework?

- Am I way off base, and in fact there is no problem with learning Struts (or any framework) and then picking up Servlets and JSP as you go?

- Are there any observations you drew from the informal survey?

Thanks to all the people who answered in the other thread.
[ July 11, 2005: Message edited by: Jason Menard ]
Ray Stojonic
Ranch Hand

Joined: Aug 08, 2003
Posts: 326
I put 3, with no explanation, on the other thread. (I'd assumed you were looking for responses not reasons for the responses)

Further, I assumed the point in time to be that moment that I began using Struts, at which time I didn't know Servlets or JSP. HTML, JS, and CSS was the limit of my web-based experience, (maybe the rare applet here and there).

Anyway, here's my Struts Story.

Newly graduated with CS degree, no job, take 'to pay the bills' non-tech position, friend of a friend is hired away from 'intership', interview, accept, I have a programming job

I'm pretty sure my job doesn't describe an internship as I am immediately responsible for the HR website and all HR web development work occuring...and my direct reports are limited to...me. Not bad for an intern in 40K employee division of a massive corporation.

So, on his way out the door, my predecessor mentions that he's been working with Struts on his latest project and I should check it out.

Assuming that my firm grasp on Java would lead the way to Struts excellence, I dove into the nearest book and began to read.

A week later I'd learned that my firm grasp was more like a vague idea and that Struts was the most convoluted thing I'd ever seen in my life.

After the week spent reading, I began looking at the emails that were coming in complaining about how this app or that feature wasn't working and realized, after some code examination, that: I didn't understand how servlets worked, my predecessor had had a vague idea of how they worked, and wasn't a terribly good programmer. (much of his code seemed to ask "Methods? Bah, why bother with that when I can just copy and paste?")

I spent a good while with my mentor, again: me, and we/I decided that I should read the servlets and jsp books my thoughtful predecessor had left behind, fix the servlet problems being reported, thereby learning something about servlets and jsp in the process, then get back to Struts and the new development work.

After a month I had the first app back up, after 3 months I had all 5 apps back up, after 6 months I had the Struts app up (A Project Management application for engineering, 6 page 'wizard' record interface, with file uploading, automatic emails, LDAP integration, role based interfaces, etc...it would take an additional 12 months to finish all the 'can it do this?' requests, all those books and they never once mentioned the perils of scope creep )

So...I'd say I'm really a 2. In fact, even if you attempted to learn Struts with being a 3 in mind, you would still be a 2 because there is no way to learn to write without learning the letters first.
Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
Originally posted by Ray Stojonic:
So...I'd say I'm really a 2. In fact, even if you attempted to learn Struts with being a 3 in mind, you would still be a 2 because there is no way to learn to write without learning the letters first.


But I think that some people are doing just that, whether by choice or by being put into such a position by their employer. I have no problem answering basic questions about the Servlet API, but when someone doesn't yet have a handle on Servlet basics such as the use of the HttpServletRequest and HttpSession objects for example, then the question begs asking what are the circumstances that made one pick up Struts.

I think this walking before we can crawl thing shows up in another aspect, which is a fundamental confusion as to what Struts is. Often we will see people wondering whether or not you can "do X with Struts", where X is something like generating a PDF view or whatever. To me this exhibits a more basic misunderstanding on what the role of an application framework is in general, and what the role of Struts is in particular. I would hazard a guess that many these types of misunderstandings stem from a more basic lack of understanding conerning Servlets and JSP since the answer to almost all of these questions is if you can do it with a Servlet, you can do it with Struts.
Pranav Sharma
Ranch Hand

Joined: Oct 27, 2003
Posts: 258
I agree with you Jason. I put myself down as a 2.

My story, I worked with applets and lot of static stuff. However i decided to work on my Masters and once I was done I had some servlet "experience" under my belt but maybe not good enough to work on professional apps. Got a job, and the first thing i needed to do was learn struts ( i had some exposure to the MVC framework). anyways i read books, worked on tutorials and got an idea abt struts. But your struts app is as good as your servlet knowledge. I know cause there were so many things you could do and understand when you knew your servlets better.
So i had to stop struts and started improving my servlets( these were very long nights with very little sleep and a lot of caffeine)

Right now, I'm not even a mid-level struts developer, but im working at it.

Now i see, the new recruits ( i'm talkin, fresh from college) who have no servlet introduction, have to take over the app I have been building. I'm supposed to be mentoring them and the first thing I got them doing was read up on servlets & jsp's only.

But the manager has them down for completing pages by july 22!!! . what are they gonna do, listen to me and read about servlets or copy/paste actions and jsp's, so they make their deadline and keep their jobs.
My guess, the later.

I don't like it a bit, but what is a junior developer to do.

-mannu
chowdary Thammineedi
Ranch Hand

Joined: Aug 16, 2004
Posts: 126
2 here with SCWCD.

3 may work, it didn't for me. I remember taking a look at STRUTS after working through some chapters of Java Servlet Programming. But I found it hard to SEE how it actually worked. I actually found that there was nothing I could learn from STRUTS at that stage. Looking back, I really find it funny that I tried it.

What can a controller do if you have nothing to control?

Now I know lot more about Servlets and JSP, and all those nights spent on SCWCD forum, Tomcat Bugzilla and wading through Tomcat source code are finally paying off. I spent an entire day trying to make a Hello World custom tag work. STRUTS looks glorious now. Learning a better way to do things is indeed fun.
chowdary Thammineedi
Ranch Hand

Joined: Aug 16, 2004
Posts: 126
Sorry for the irrelevance of this post to your question. But I just realized I know how you look. I have your photograph in my HF Design Patterns book. Infact I know how a lot of bartenders here on the ranch look like.
Betsy
Greenhorn

Joined: Jul 11, 2005
Posts: 6
i am new to struts & i am facing a problem. the application goes to the .do file which is blank. Can anyone help.
this is my code.
struts-config
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">

<struts-config>
<form-beans>
<form-bean name="registerForm" type="app.RegisterForm"/>
</form-beans>
<action-mappings>
<action path="/register" type="app.RegisterAction" name="registerForm" scope="request" input="/register.jsp">
<forward name="success" path="/success.jsp"/>
<forward name="failure" path="/failure.jsp"/>
</action>
</action-mappings></struts-config>

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

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

<web-app>
<display-name>Struts Blank Application</display-name>

<!-- Standard Action Servlet Configuration (with debugging) -->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>


<!-- Standard Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>


<!-- The Usual Welcome File List -->
<welcome-file-list>
<welcome-file>register.jsp</welcome-file>
</welcome-file-list>


<!-- Struts Tag Library Descriptors -->
<taglib>
<taglib-uri>/tags/struts-bean</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>/tags/struts-html</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>/tags/struts-logic</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>/tags/struts-nested</taglib-uri>
<taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>/tags/struts-tiles</taglib-uri>
<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
</taglib>

</web-app>

RegisterAction.java
// RegisterAction.java

package app;
import org.apache.struts.*;
import javax.servlet.http.*;
import java.io.*;

public class RegisterAction extends Action
{
public ActionForward perform(ActionMapping mapping,ActionForm action,HttpServletRequest req,HttpServletResponse res)
{

return mapping.findForward("success");

}
}
RegisterForm....this is not required...but still i have given it

// RegisterForm.java

package app;
import org.apache.struts.*;
public class RegisterForm extends ActionForm
{
protected String username;
protected String password1;
protected String password2;

public String getUsername()
{
return username;
}
public String getPassword1()
{
return password1;
}
public String getPassword2()
{
return password2;
}

public void setUsername(String username)
{
this.username=username;
}
public void setPassword1(String password1)
{
this.password1=password1;
}
public void setPassword2(String password2)
{
this.password2=password2;
}
}

register.jsp
<%@taglib uri="/WEB-INF/struts-html.tld" prefix="form"%>
<form:form action="/register">
username<form:text property="username"/>
password<form assword property="password1"/>
confirm password<form assword property="password2"/>
<form:submit value="register"/>
</form:form>
success.jsp
//success.html

<html>
<body>
Success !!
Registration Succeeded!!
<a href="register.jsp">try again</a>
</body>
</html>


Please help
Tim West
Ranch Hand

Joined: Mar 15, 2004
Posts: 539
I think LLL implied a fourth option - "None of the above, I asked Javaranch to learn them all for me"

My answers to Jason's questions, though:

Why I learned Struts before JSP/Servlets

When I first started with Struts I was an intern at a big ol' company, working on a J2EE development project. A fairly well-formed framework was in place, so I could copy what was there, hardly learning much about Struts itself, let alone the others. This is certainly not my preferred way to work, but there were no learning resources made available to me on JSP/servlets (resources = books, courses, time), but I did get a Struts book by chance. Basically, it came down to needing to know Struts now, and happening to have the right book for it. I certainly don't think this is a good way to learn it all, though.

This year, as part of my thesis, I needed a small demonstrative Web app, and so used Struts by default, since it was what I was most familiar with. Again, I was/am pushed for time. I was forced to learn a small amount about servlets when I set up Struts ("hmm, the book says I need this snippet of XML in web.xml relating to 'StrutsActionServlet'"), but still nothing serious.

I've found that my (lack of) knowledge has been adequate for these two scenarios: one where others did the difficult plumbing, and the other where there was very little plumbing to do - my research app has no security, minimal session handling, etc etc. However, I'm fully aware that I am still largely unable to architect a respectable solution that incorporated Struts/JSP/servlets, security, etc. While I could make a solution work, I wouldn't be able to give reasoned arguments as to why it was like it was, etc, if a suitably knowledgable person were to criticise my design.

On junior developers

Regarding junior developers (i.e., me last year), it's a little tough - learning style differs from person to person. For me, I reckon the ideal would have been to work on the application for a while, then have some time set aside for learning fundamentals, ideally as part of a course (perhaps leading to SCWCD or similar). The course could have been part time while I was developing.

That's an ideal situation, mind - the company I was with wasn't willing to do that sort of thing. As a second option, a few decent books and some time set aside for study would have been great.

On learning Struts before JSP/Servlets

IMO, there is nothing wrong with learning Struts before JSP/Servlets, but there is definitely a problem if you fail to ever learn the latter. I reckon some people will shy away from the theory, while others will be keen to understand what's really going on. That stands for virtually any area - I noticed this when tutoring at uni.

Where there is a problem is learning Struts before you have a reasonably clear picture of Java/J2EE and what each vague area does. When I learned Struts, I already had a decent idea of EJB, the three teir architecture, and the purpose of Struts within the general scheme of J2EE applications. People that ask stuff about struts and PDF like Jason wrote (another I've seen is "Connecting to MySQL with Struts") are lacking in much more than JSP/Servlets knowledge - they have no real idea of application architecture at all!

Anyway, my $0.02...And now, I have a thesis to work on!

Cheers,


-Tim
[ July 12, 2005: Message edited by: Tim West ]
Betsy
Greenhorn

Joined: Jul 11, 2005
Posts: 6
can anyone help me in figuring out the error
Tim West
Ranch Hand

Joined: Mar 15, 2004
Posts: 539
On the subject of "overall J2EE architecture" being (perhaps) the most important area for people new to web development to understand, here is another post reflecting confusion as to the role of JSP/Servlets themselves - even before Struts is introduced.

The thread title is "JSP/Servlet With MS Excel?"

"LLL LLL", if you want a meaningful response to your question, I'd post it as a separate topic. This thread is not really the right place. You might want to check the Javaranch username guidelines, which disallow 'obviously fake' names. Finally, if you want people to take your question seriously, it's worth taking the time show that you take it seriously - by writing it in correctly spelt and punctuated English.



-Tim
[ July 12, 2005: Message edited by: Tim West ]
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

To take this further, I think a lot of folks try learning JSP/Servlets (or Struts) before learning basic HTTP and HTML concepts. So often people don't understand how a basic webapp functions nor do they understand its limitations.

Servlets made dynamic html pages easier. JSPs made view-centric Servlets easier. Struts made organizing JSPs and Servlets easier.

Struts solves some problems but it is hard to understand how it works without understanding the problems that it solves. And it's hard to understand the problems without the frustrating experience of trying to solve them on your own.

This is one of the reasons why I'm excited about JSF, as it seems to make the basic webapp concepts very transparent to the developer. I think the initial learning curve will still be close to that of Struts but the curve will take more of a Swing-like (and dare I say cleaner) approach.


A good workman is known by his tools.
Tim West
Ranch Hand

Joined: Mar 15, 2004
Posts: 539
Marc - what you observe certainly rings true for me! (Not my own learning path, but what I've observed in others).

Another issue that's related is "learning" use of Java and libraries through a tool - usually a modern IDE. I'm motivated by a question in this thread, namely "How can I add Struts capabilities without a Struts plugin?" Here, the concept of Struts is blurred with that of a tool that helps you write a Struts application. This is separate from the blurring between Struts/JSP/servlets/HTTP etc - and perhaps more fundamental than it.

It seems to me that a possible, bad, (common?) path for learning Java web app development is:

  • First, learn Java using an IDE. Overlook many concepts that the IDE helps you around, and fail to get a strong understanding of Java concepts For example, a user won't ask "what's a JAR?" but will say "The export JAR function in Eclipse won't work"***, or "How can I make an .exe with Netbeans?"
  • Second, build a Web app using an IDE. The IDE generates all sorts of XML files, WARs, and automatically sets up Struts.


  • For the moment I just wanted to point out this related problem...the solution? I dunno - make them use vi?!


    -Tim

    *** Note, a very real question on Eclipse JAR export was posted recently, and this was certainly a legitimate question. I'm not getting at this sort of question, rather at questions that demonstrate a lack of clear separation between "JAR" and "Eclipse's JAR export function".
    [ July 12, 2005: Message edited by: Tim West ]
    Jason Menard
    Sheriff

    Joined: Nov 09, 2000
    Posts: 6450
    Good point Tim. I think it's the whole thing with people wanting to run before they learn how to walk which I mentioned in the first post. While I'm sure that job demands are a big part of this, I get the impression that all too often this kind of thing is self-inflicted.
    Barend Garvelink
    Ranch Hand

    Joined: Dec 07, 2004
    Posts: 64
    I recognise everything Marc and Tim have written here. Many of the questions posted stem from a fundamental lack of understanding about how Java works, hpw the web container works, and how HTTP communication works.

    An example I'd like to chip in on my own is the JFreeChart forum where (awhile back at least) one or two times a week someone would ask why the java.awt.Image he <%='d into his JSP page didn't show up.

    The question now, of course, is how do we get the world at large to spend a few weeks with a text editor and javac before firing up an IDE?
    [ July 24, 2005: Message edited by: Barend Garvelink ]

    SCJP 1.4, SCJD 1.4, SCWCD 1.3, ICSD:Websphere 5.1
    Manish Hatwalne
    Ranch Hand

    Joined: Sep 22, 2001
    Posts: 2581

    Originally posted by Barend Garvelink:

    The question now, of course, is how do we get the world at large to spend a few weeks with a text editor and javac before firing up an IDE?

    [ July 24, 2005: Message edited by: Barend Garvelink ]


    Very true!!!

    - Manish
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Learning Struts before Servlets and JSP (follow-on to Struts Survey post)