Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting too large try statement in JSP page

 
jai KM
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

i getting code too large for try statement, when i opening one of my JSP file. File size is around 2000 lines.
Could anybody tell me the reason for that error. is it because of the restriction in java compiler?.
if u have any alternatives let me know...


thanks in advance...

regards,
 
Daniel Rhoades
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
2000 lines of code in 1 file is obscene!

Separate you code into logical function and put them into other JSP pages - or better yet servlets or tag libraries.
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are not in a position to modularize 2000 line code, try to cover up your existing code with multiple try/catch block.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"jai KM",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender
 
Ajay Krihnamurthy
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi 2000 lines is not a big issue in a jsp page. U can do onething use multipe try{}catch(Exception e){System.out.println(e.getMessage());} with inur jsp code .. From the tomcats log folder u can get the appropriate error message for ur exception



once if u cant sove that error please let me know
 
Choon-Chern Lim
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
2000 lines in JSP is not the problem, but it will be a massive problem once you get exceptions. In my past experience, it is difficult to debug the code.

I would suggest you breaking up the codes, where you place your JAVA codes in servlets, your presentations (HTML/JSP tags stuff) in JSP, and your client side script (Javascript) in JS file. At least, when other developer reads your codes, they are not going to get lost in the sea of codes.

Another beauty of having your codes in servlets is that you can easily debug your codes by putting break points in IDEs like Eclipse/WSAD/RAD.

I guess my point is that you want to be able to able to read your own codes in 3 months time.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic