Hi All,

I don't know if I'm asking it right. I have a jsp for monthly report that calling java class and passing date parameter (year and month) into that java class. The java class has a statement that call procedure in database. It's so time consuming to show the report. But when I do hardcode in procedure for date parameter, the report shows much faster. I already checked the passing parameter and it has correct value. Any idea how this thing can happen? Thanks for your reply.

Hey there, okay so the reason why hardcoding the value in your class is way faster than having the JSP send the information in the class is because:
Before a JSP gets executed, it is first converted to a servlet/class on your server (Like Tomcat etc.). That class is then stored who-knows-where inside your server files, and then only is it run by the JVM... Hardcoding avoids all of that and just has the class get executed straight away...

Makes sense?:)

hi dean_gobler thanks for your reply. Ah..I see what you mean. But, do you know how to make it faster? Because when hardcode it's only take 1 minute, but when I used parameter it will take 10 minute. It's impossible to use hardcode because user can choose the year and month (parameter) from combobox. :(

Wow, I didn't know when you said slow you really meant slow!. That seems a bit unusual. I don't exactly knwo how you can make it faster, because the JSP HAS to get converted to a class before it can run... I understand that you can't hardcode it in there, that would be useless..

I guess it depends what your JSP looks like. How much lines of <%%> java go do you have in your JSP pages?

*****************Edit****************
Or is it just a normal HTML <form> the user fills in that then gets sent to the servlet?

I have many lines of <%%> java in my JSP pages. Is it giving much impact?

I have many lines of <%%> java in my JSP pages. Is it giving much impact?

it has a major impact on maintainability.
Ideally there should be no Java code in your JSPs at all.

Yes most definitely. Like jwenting said, keep java code in your JSP to an absolute minimum. I wouldn't say no java code, but say you have 50 lines of Java code in your JSP, rather put that code in seperate java file and only have one line of java code in your JSP calling that class.

It is considered bad practice having so much java code in your JSP. Keep java code in seperate files, that's my advice...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.