Solved

Servlets/jsp

Posted on 2014-03-03
5
534 Views
Last Modified: 2014-03-10
I would like to know whats suitable to be used from below:
1. From JSP call servlet to create a xml file and pass back to jsp and then display on jsp OR
2. Call a plain java class using a scriptlet from jsp which will create xml and return to jsp.
I would like to understand the difference/benefits/drawbacks in using the above approaches.

Also in servlets is it bad to have global variables? Does that have any risk?
0
Comment
Question by:michaelm702
  • 3
  • 2
5 Comments
 
LVL 27

Expert Comment

by:rrz
Comment Utility
What will initiate the call to create the XML? Will the user click a button or a link?
>Also in servlets is it bad to have global variables? Does that have any risk?
What kind of data would it hold?  Is it something that won't change? Is it the same value for all users of your web app? Do you know about scoped objects? If not, then look at
http://docs.oracle.com/javaee/1.4/tutorial/doc/Servlets5.html
0
 

Author Comment

by:michaelm702
Comment Utility
The user will open the jsp and when it loads I was thinking of calling java class using scriptlet.
for servlet i was planning to put a submit button which will call servlet.
Global variable few have contant value and others values can change as per the user calling the jsp. For e.g. I have a form which takes two numbers and operation(add,subtract etc..)
so the users accessing my application will always supply two number and a operation so one user says 2+3 and other 3-2..
0
 
LVL 27

Expert Comment

by:rrz
Comment Utility
>The user will open the jsp and when it loads I was thinking of calling java class using scriptlet.
Do you mean to say that the user will request the JSP. The server will respond with the JSP's output. When it loads in the browser, it is on the client-side. Could you use javascript to create the XML? Or do you need some data from the server?
>so the users accessing my application will always supply two number and a operation
That sounds like you could use session-scoped objects on the server or just use javascript in the browser .  

Please describe how you want your web app to work in more detail.
0
 

Author Comment

by:michaelm702
Comment Utility
I am just trying to see the best practice that needs to be followed.

Do you mean to say that the user will request the JSP. The server will respond with the JSP's output. When it loads in the browser, it is on the client-side. Could you use javascript to create the XML? Or do you need some data from the server?
-> I need some data from server too.
0
 
LVL 27

Accepted Solution

by:
rrz earned 500 total points
Comment Utility
>I am just trying to see the best practice that needs to be followed.    
The popular approach is to use a web framework. There are a lot of them. Look at  
http://en.wikipedia.org/wiki/Comparison_of_web_application_frameworks#Java  
http://zeroturnaround.com/rebellabs/the-curious-coders-java-web-frameworks-comparison-spring-mvc-grails-vaadin-gwt-wicket-play-struts-and-jsf/
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now