Custom Tag Lib in 4.5

I don't like using web modules in idea. I'd rather use ant to do the packaging. In Idea 4.0 I had the struts.jar in my project path and

<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>

used to work. Now in 4.5 I get "Cannot resolve tag library" no matter what I do. Is there something broken in 4.5 or am I now forced to use web modules?

Thanks in advance,
Roozbeh/

17 comments

Hi,

Web module is required

Roozbeh Ghaffari wrote:

I don't like using web modules in idea. I'd rather use ant to do the packaging. In Idea 4.0 I had the struts.jar in my project path and

<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>

used to work. Now in 4.5 I get "Cannot resolve tag library" no matter what I do. Is there something broken in 4.5 or am I now forced to use web modules?

Thanks in advance,
Roozbeh/



--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0

I really miss the way this used to work in 4.01. I am working from a cvs directory structure that does not conform
to the classic WEB-INF structure. My classes are compiled and then assembled and packed into a .jar in WEB-INF/lib before the final packaging/deployment. In 4.01 it did not
matter as long as struts.jar was in the class path. Why the change.

0

Exactly! As a matter of fact, it's not a good practice to maintain the WEB-INF structure in your source files at all. It's not suitable except for very small projects.
The thing I love about idea is that it helps you do your job the way you like to do it, not force you do it in a specific way. Forcing the organization of files in your program is one if the worst thing an IDE could do.

0

Hi,

- IDEA does not force anyone to organize the source directories with
WEB-INF (META-INF) structure, instead, the exploded directory should
conform to specified structure. This is important, because:
- Working with your tag libraries IDEA 4.5 evaluates their location and
used classes as the web server would do during runtime, namely, from
exploded directory. Thus for correct work with tag libraries one needs
to have the library classes copied into exploded directory WEB-INF/lib
(set up in Modules and Libraries to Package) and tag library descriptors
(tld) copied into exploded WEB-INF (e.g. this could be achieved with
specifying web resource root mapped into exploded directory with prefix
WEB-INF - this is done automatically in 4.5.2)

Roozbeh Ghaffari wrote:

Exactly! As a matter of fact, it's not a good practice to maintain the WEB-INF structure in your source files at all. It's not suitable except for very small projects.
The thing I love about idea is that it helps you do your job the way you like to do it, not force you do it in a specific way. Forcing the organization of files in your program is one if the worst thing an IDE could do.



--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0

Hi Maxim,

Thanks for your reply!

- This used to work in IDEA 4.0x, so it is possible.
- In JSP 2.0 there is no need to copy the tld files into WEB-INF. Once you have access to the jar file, the tld files are in it. That's how IDEA 4.0x works. You put the jar file in project path and each individual jsp file can benefit from the marvelous editor of IDEA no matter where it is.
- That said, I still can't see a reason for having to use web modules in order to have access to jsp editor features. After all, this used to work IDEA 4.0x! :)

0

Hi,

- When IDEA will support of JSP 2 (in 5.0) the handling of tld files
will be different for web app using such jsp version. But even then IDEA
will use web container tld resolving approach. This is done in order to
have no runtime problems in server tld resolving when the web module is
about to run on the server.
- I will really appreciate some cons for the usage of the web modules.

Roozbeh Ghaffari wrote:

Hi Maxim,

Thanks for your reply!

- This used to work in IDEA 4.0x, so it is possible.
- In JSP 2.0 there is no need to copy the tld files into WEB-INF. Once you have access to the jar file, the tld files are in it. That's how IDEA 4.0x works. You put the jar file in project path and each individual jsp file can benefit from the marvelous editor of IDEA no matter where it is.
- That said, I still can't see a reason for having to use web modules in order to have access to jsp editor features. After all, this used to work IDEA 4.0x! :)



--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0

What's the problem with having a web module? It seems funny to use a
java module for what is clearly a web module. If you use the web
module, everything will work correctly.

You will need to redefine your projects, but it does come with many
benefits.

Norris Shelton
Sun Certified Java Programmer




Roozbeh Ghaffari wrote:

>Hi Maxim,
>
>Thanks for your reply!
>
>- This used to work in IDEA 4.0x, so it is possible.
>- In JSP 2.0 there is no need to copy the tld files into WEB-INF. Once you have access to the jar file, the tld files are in it. That's how IDEA 4.0x works. You put the jar file in project path and each individual jsp file can benefit from the marvelous editor of IDEA no matter where it is.
>- That said, I still can't see a reason for having to use web modules in order to have access to jsp editor features. After all, this used to work IDEA 4.0x! :)
>
>

>

0

Hi,

- My mistake! I meant JSP 1.2.
- The reason I'd rather not use a web module is that my project's structure won't fit into one. I have an src directory (checked out from cvs) that has separate directories for java source files and web content. There is no WEB-INF/web.xml in my src/web directory. It's automatically generated by xdoclet. The structure looks like this:

prj (project root)
+-- lib (library files, check out from cvs, binary)
+-- build (used by ant to create class files)
+-- dist (war file is placed here)
+-- gen (source files generated by xdoclet, xml and java)
+-- src (source files, checked out from cvs)
____+-- java (java source files)
____+-- xml (xml files from spring, struts, xdoclet, etc.)
____+-- web (jsp,html,css,images,etc.)

As you see my web content are in src/web, but there is no WEB-INF and/or web.xml in that directory. Those are created by ant and xdoclet. How can I fit this into a web module? Note that I don't want to check-in xdoclet generated files into cvs. Only src and lib are in cvs. Other developers are able to use any other IDE they like, because everybody uses ant to do the build process. That's why I don't want to use a web module.

0

I went ahead and converted my java module to a web module
and the only real difference is I have big WEB-INF directory
with minimal web.xml in it in my project now. I now have taglib recognition again but still prefer it the old way.
I like to keep build,lib,src,pages,devlib directories all on the same level as my build.xml file. That breaks the web-inf model but offers better seperation of logic in my case.

0

Hello Norris,

NS> What's the problem with having a web module? It seems funny to use
NS> a java module for what is clearly a web module. If you use the web
NS> module, everything will work correctly.
NS>

Here's one of the reasons that, so far, forced me to not take advantage of the web modules: my module files are automatically generated from an Eclipse structure, and since Eclipse projects don't make this distinction (at least I haven't figured out how it's done, if it is done) all the resulted modules are java modules. I prefer to have the libs and all the other stuff created automatically (lots of dependencies and third party libraries are involved in the whole thing) instead of having to specify them manually. And I generate the modules periodically, just to be sure I don't miss changes in the Eclipse projects structure.

Since there is no easy way to convert a java module into a web module (apart from messing with the iml file), so far I used only java modules. It's been dissapointing enough to not be able to take advantage of the taglib support in JSPs, so I'll probably have to hack the import code some more, eventually.

But these are things that don't help me with my job. For all the nifty things that have been added to the web support in the latest versions, I find IDEA 4.5 less usable than the older versions when it comes to basic web support. And, since I'm stuck with Websphere, all the other fancy bells and whistles are worthless to me.

Best,
Andrei

0

Hello Maxim,

MM> - I will really appreciate some cons for the usage of the web
MM> modules.

I wouldn't have a problem with web modules per se if I could easily convert an existing java module into a web module, preserving all the dependencies and library definitions and not having to provide all the details I don't need to know about. Having to start from scratch just to be able to use the taglib support is not too user friendly.

IDEA is not helping me here: it forces me to deal with lots of details I don't care about (basically everything else beyond editing JSP files) just so I can take advantage of the taglib support.

Just my 2c,
Andrei



0

Actually, for that to work in 4.0, you had to set up a web resource. So that "didn't work" the way you seem to imply that it did.

0

No! Here is what I just did in 4.03:

New project, single java module.
Add struts.jar to project path.
Create a file test.jsp with the following header:

<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>

I got no errors.
Now type "<html:" and hit Ctrl+Space and see what happens.

0

That sounds like a very good RFE. Please enter it and you will have my
vote.

Norris Shelton
Sun Certified Java Programmer




Andrei Oprea wrote:

>Hello Maxim,
>
>MM> - I will really appreciate some cons for the usage of the web
>MM> modules.
>
>I wouldn't have a problem with web modules per se if I could easily convert an existing java module into a web module, preserving all the dependencies and library definitions and not having to provide all the details I don't need to know about. Having to start from scratch just to be able to use the taglib support is not too user friendly.
>
>IDEA is not helping me here: it forces me to deal with lots of details I don't care about (basically everything else beyond editing JSP files) just so I can take advantage of the taglib support.
>
>Just my 2c,
>Andrei
>
>
>

>

0

Hello Norris,

Here it is:
http://www.intellij.net/tracker/idea/viewSCR?publicId=38317

Best,
Andrei

NS> That sounds like a very good RFE. Please enter it and you will have
NS> my vote.
NS>

0

Hi,

When you create the web module you can actually set the directories
where the web.xml is located, and also web resource and java source
directories so map:
web resource directory to src\web
java source files src\java
web.xml where you like it

IDEA will build the web app structure (WEB-INF) in exploded directory
(also configurable).
So you will have proper jsp support without changing your project layout.

Roozbeh Ghaffari wrote:

Hi,

- My mistake! I meant JSP 1.2.
- The reason I'd rather not use a web module is that my project's structure won't fit into one. I have an src directory (checked out from cvs) that has separate directories for java source files and web content. There is no WEB-INF/web.xml in my src/web directory. It's automatically generated by xdoclet. The structure looks like this:

prj (project root)
+-- lib (library files, check out from cvs, binary)
+-- build (used by ant to create class files)
+-- dist (war file is placed here)
+-- gen (source files generated by xdoclet, xml and java)
+-- src (source files, checked out from cvs)
____+-- java (java source files)
____+-- xml (xml files from spring, struts, xdoclet, etc.)
____+-- web (jsp,html,css,images,etc.)

As you see my web content are in src/web, but there is no WEB-INF and/or web.xml in that directory. Those are created by ant and xdoclet. How can I fit this into a web module? Note that I don't want to check-in xdoclet generated files into cvs. Only src and lib are in cvs. Other developers are able to use any other IDE they like, because everybody uses ant to do the build process. That's why I don't want to use a web module.



--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0

Hi Maxim,

I still can't understand why the old method shouldn't work anymore, but thanks to you now I have my project in 4.5 without any change in its structure and the jsp editor works with no problem. I'm using a web module now.

I appreciate your help very much. Thanks!

0

Please sign in to leave a comment.