Solved

Servlets/jsp

Posted on 2014-03-03
5
535 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
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 27

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 27

Accepted Solution

by:
rrz earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

932 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

10 Experts available now in Live!

Get 1:1 Help Now