Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Servlets/jsp

Posted on 2014-03-03
5
Medium Priority
?
547 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

610 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