Please create an account to participate in the Slashdot moderation system

 



Forgot your password?
typodupeerror
×
Java Programming

Editors and Java Server Page Synax Highlighting 8

Nathan Frund asks: "VIM has been my mainstay for writing code/HTML/config files etc for a long time. But VIM doesn't hightlight JSP syntax. I've become accustomed to the syntax highlighting and can't go back to not having it. I've tried various modes for VIM but none of them really do the trick. XEmacs doesn't support it either (I haven't found where it does or even the resources to make it highlight jsp syntax) and I really don't have the time to become a VIM or an Emacs expert to write the modes from scratch. My question to all of you, What editor(s) are you using to write Java Server Pages? "
This discussion has been archived. No new comments can be posted.

Editors and Java Server Page Synax Highlighting

Comments Filter:
  • I'm not sure if it has the specific syntax highlighting for JSP, but you might try Jedit [gjt.org]. It has undergone many updates and the development seems very active.


    Personally I have gotten more minimalistic over time. I used to use IDEs and now I just use vi and let my mind (and compiler) do syntax verification. Sure, there are better things to clutter the mind with but it just feels good to use vi.
  • The only two packages I know about that support JSPs are IBM's WebSphere Studio and Macromedia's Drumbeat 2000. WebSphere is a higher end tool and Drumbeat is more of a visual designer for people who don't want to work at the code level. Both are a few hundred dollars as far as I recall. WebSphere Studio (when used with WebSphere) is unique in that it can debug JSPs in original source form, which is a real bit of wizardry becuase all JSPs must be run through the servlet precompiler before they can be run.

    -Tim Dyck, PC Week Labs
  • My suggestion would be to simply stick with the editor you like (saves a heck of a lot of time and money... and I personally have little enough of those :)

    You might like to try subscribing to the vim mailing list ( http://www.vim.org/mail.html ) and simply ask if there's anyone else out there who would be nice enough to write the syntax file and add it to the distribution. There might even be an unofficial one out there that you just don't know about. Hey, never hurts to ask...
  • I use Emacs and html-helper. Altho the syntax highlighting isn't perfect, for me, it's better than b&w. In my .emacs, I just config any scripting languages (PHP, ASP (ugh..), JSP, CFM, and many more...) to use the html helper highlighting. I've looked for something that specifially highlighted scripting stuff and I've found nothing else worthwhile.
  • Hi, I use the syntax file below. It's very rough, but I find it far more useful than nothing. Basic caveats: it forgets how to format html after a closing JSP tag. Ditto for forgetting JavaScript. But it can be handy all the same.

    You'll have to figure out where to save this file yourself; but it should work in vim5.3+

    " Vim syntax file
    " Language: JSP
    " Maintainer: None
    " URL: None
    " Last change: 1999 November 1

    " Remove any old syntax stuff hanging around
    syn clear
    syn case ignore

    if !exists("main_syntax")
    let main_syntax = 'jsp'
    endif

    " tags
    syntax include @html :p:h/html.vim
    syntax include @java :p:h/java.vim
    syn region jobby start=+ syn region jspCode matchgroup=jspDirective start=++ contains=@java keepend
    syn region jspOutput matchgroup=Special start=++ contains=@java keepend transparent
    syn region jspDeclaration matchgroup=Special start=++ contains=@java keepend transparent
    syn region jspDirective start=++
    syn region jspComment start=++ keepend

    if !exists("did_jsp_syntax_inits")
    let did_jsp_syntax_inits = 1
    hi link jspDirective Special
    hi link jspComment Comment
    endif

  • Shouldn't you be able to tell vim where jsp-code ends?

    That line in my html.vim looks like this (where it defines what is javascript):

    syn region javaScript start=+]*>+ keepend end=++me=s-1 contains=@htmlJavaScript,htmlCssStyleComment,htmlS criptTag,@htmlPreproc

    I'm not that familiar with the vim-syntax-syntax though...
  • From the comments section:

    ;; Author: Gongquan Chen

    ;; This file implements a XEmacs lisp extension
    ;; that allows multiple major modes
    ;; to co-exist in a single buffer. It's a
    ;; workable, yet imperfect, solution that
    ;; basically supports key bindings and font-lock
    ;; in those regions with a secondary
    ;; major mode. To activate one secondary major
    ;; mode, simply add a hook to the
    ;; primary major mode's hook. For details, see
    ;; defun `mmm-activator'.

    Unfortunately, it's pretty big to try to actually post as a comment and there's no URL in the comments of the LISP file. You'll probably have to search through something like Altavista for 'mmm.el' or search on Deja.com or just write the author and see where you can pick up a copy.

    I use it myself for about a year or so with XEmacs (It requires a 21.x version to work correctly) and it works about 99% perfectly with HTML and whichever scripting language I happen to be embedding. (It actually uses a major-mode for the scripting language, so for JSP, the "primary major mode" is HTML except when your cursor is inside <java> tags in which case mmm switches to JDE mode.)

    There are a few global settings, like TABs I think, that it doesn't change because the "primary major mode" sets them globally and they won't get changed when you enter the "secondary major mode" but they're really pretty minor issues. (Pardon the pun.)

    The main drawback is you will have to learn a *little* bit of LISP hacking to set up the filters to let mmm know when to switch modes, but there are enough examples in the comment section of mmm.el that you can pretty much just cut-n-paste to get it to work for your particular situation.

    -=-=-=-=-

  • Dangit ... /. stripped out the EMail address of the author 'coz of the brackets:

    Gongquan Chen (chen@posc.org)

    -=-=-=-=-

Any program which runs right is obsolete.

Working...