Solved

Servlets/jsp

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This video teaches viewers about errors in exception handling.
Suggested Courses

738 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