?
Solved

Servlets/jsp

Posted on 2014-03-03
5
Medium Priority
?
542 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 28

Expert Comment

by:rrz
ID: 39902369
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
ID: 39902396
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 28

Expert Comment

by:rrz
ID: 39902592
>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
ID: 39909958
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 28

Accepted Solution

by:
rrz earned 1500 total points
ID: 39910157
>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

AWS Certified Solutions Architect - Associate

This course has been developed to provide you with the requisite knowledge to not only pass the AWS CSA certification exam but also gain the hands-on experience required to become a qualified AWS Solutions architect working in a real-world environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month15 days, 17 hours left to enroll

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