Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Moving run time issues to compile time

 
Yogesh Gandhi
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Friends,

A very frequent problem I face with JSP's. I have an idea, I want you guys to comment if such a thing already exists in market or not...

In our projects we usually use <bean:message tag...where we refer to Resource.properties for the key...

And many times, we do forget to add that key in resource bundle, or it gets missed by mistake during merging process.....

In such a scenario, it gives a white screen when JSP is accessed on websphere... and one has to go to system logs to check where is the problem... and if such mistake happens to be in production environment, that is even worse.... Client yells on me...

So, i was wondering, if it could be possible to identify this issue at compile-time, during the compilation of JSP...because, its a general practice of developer that he atleast compiles his JSP before merging it to production....So if such an error comes at compile time, he could be saved of issues that might come up at run time...

What do you guys have to say about this?
Is there any such product already existing in market? or this is practically impossible or any thing that comes to your mind !!!

Waiting for your responses...
>
 
Moises Lejter
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ideally, this would be something that you could get the IDE to validate for you...

As an alternative, there's a question on stackoverflow that discusses several alternatives, when one is trying to use Java constants in JSP EL expressions:
http://stackoverflow.com/questions/3732608/how-to-reference-constants-in-el

The suggestion in the question, though, is one way in which you could get compile-time validation that you are indeed defining all the constants you'd need: you can use
<%=Addresses.URL%>
to reference Java constants by their name.

You could then define a class that defines a Java String constant for each key you intend to use, then reference keys in your JSPs by using references to the Java constants in your class.
If you now compile all your JSPs before deploying the application, any reference to a String constant that is not in your class will result in a compile-time exception when compiling that JSP...

Granted, this wouldn't help you, if you forget to define the value for that key...

Moises
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic