1

may be it is not a worthy question but i am new at angular js that is why going to ask this ! I have a small portal which has forms develop in jsp. Now my requirement is to display data from db on page by not moving to next page using Angular JS. Can i do this easily using jsp? or I should use c#? But transferring from jsp to c# will be quite daunting task! I shall be very great full if someone suggest a way using jsp.

Kind Regards.

Michail Michailidis
  • 11,792
  • 6
  • 63
  • 106
NN796
  • 1,247
  • 11
  • 31

1 Answers1

0

If you can return/echo json files from JSP and you can consume requests (get,post,update delete) coming to it and redirect it to whatever handles the business logic (e.g controllers) then you are set to go. I believe with JSP you mean JSP + Java Servlets + Java Beans. Or in other words controllers better be Java classes. If that is your case, then you definitely can do that without converting to C# + ASP.NET ;)

Update:

The fact that you are only using JSP is good for starters but as you get better and want the application to scale more you need to move talking with the database in a Java class/servlet. JSP should be used only for presentation/templating and no business logic (if/else this that). Now you are consuming your request names from the form like username password etc.. With angularJS will be the same. The main difference is that angular will submit the form with ajax so no page redirection will happen (there are many questions in stackoverflow how to stop a form from submitting). Then the JSP will have to return/print some json and this will be returned to angularjs for rendering that in your page.In other words there will be no html in your JSP. All the templating will happen in the client side (Javascript/AngularJS)

Links:

Community
  • 1
  • 1
Michail Michailidis
  • 11,792
  • 6
  • 63
  • 106
  • Michail Michailidis i have a form in jsp and i am storing records in db using jdbc, now i have to use angular js to display above mentioned records on a page by not moving the page ? can you help me out as i am a beginner and not very much familiar with new web technologies ! – NN796 Oct 27 '14 at 13:28
  • What are you using in the backend for consuming the data and talking to the database? Do you have java classes or you do everything in jsp? – Michail Michailidis Oct 27 '14 at 13:29
  • every thing in jsp ! using jdbc ! – NN796 Oct 27 '14 at 13:30
  • 1
    got it @Michail Michailidis, is there any tutorial which explains this step by step so that i can implement it ! ? Regards. – NN796 Oct 27 '14 at 13:43
  • Did you check my links? You have to do a bit more reading for MVC, Server/Client side code and understand all those before jumping in AngularJS which a powerful tool but quite difficult if you are doing your first form submissions now. – Michail Michailidis Oct 27 '14 at 13:44
  • I added a full list of links - hope this helps ;) There are videos/interactive courses/book and articles – Michail Michailidis Oct 27 '14 at 13:56
  • I added a tutorial that shows how Java + AngularJS should work together. It is possible that you don't even need jsp and you have to do all these things in plain Java Classes/Servlets – Michail Michailidis Oct 27 '14 at 14:03
  • 1
    I am going through it , if there is any problem i will ask you and disturb you little more again :p – NN796 Oct 27 '14 at 14:19
  • Absolutely! Feel free to do so! Make sure to understand all the concepts and not just the technologies (that's why I gave you all these resources). It took me weeks and weeks to understand the basics of angularjs even though I am coding for 15 years and I have a strong knowledge about how things communicate no matter what the language/framework. Btw thanks for accepting the answer :) – Michail Michailidis Oct 27 '14 at 14:22
  • I shall be very grateful to you if you give me some tutorials as well for .net (C#) with Angular js for future reading and understanding ! Regards! – NN796 Oct 27 '14 at 14:39
  • That was more difficult to find a good one - I believe this one is easy enough to follow: http://www.codeproject.com/Articles/806029/Getting-started-with-AngularJS-and-ASP-NET-MVC-Par – Michail Michailidis Oct 27 '14 at 14:45
  • Thank you so so much ! What if the need is about: How to send JSON from .net (c#) to Javascript ? – NN796 Oct 27 '14 at 14:51
  • Keep in mind that if AngularJS Framework is not a requirement you can stay in the same page and not redirect by using jQuery library or plain Javascript (way different style compared to AngularJS Framework) - Do you require AngularJS or you can avoid it? – Michail Michailidis Oct 27 '14 at 14:52
  • This is the relevant question about sending JSON from C# http://stackoverflow.com/questions/11625917/sending-a-string-like-json-from-c-sharp-to-javascript – Michail Michailidis Oct 27 '14 at 14:54
  • it is a requirement :/ ! – NN796 Oct 27 '14 at 14:54
  • Oh :( That is sad - most of your code will need to be rewritten and refactored assuming that most of it is hidden in jsp ( bad practice btw as I said before). It will be painful but you will learn a lot since AngularJS is really opinionated framework and you are pushed (most of the time) to separate your code correctly. Be careful though not to do MVC separation both on Server side and client side. What I suggest is use Java Servlets or C# Http request handlers and consume/send json only. All the other stuff including html/templates will be handled by AngularJS – Michail Michailidis Oct 27 '14 at 14:58
  • got it, i have develop a simple application for my practice in .net (c#) ,i have store some records manually in db attached with visual studio 2013, now how can i get records from db using angular ajax ? – – NN796 Oct 27 '14 at 15:28
  • This is getting a bit offtopic.. but anyway I would have C# handlers like (http://msdn.microsoft.com/en-us/library/vstudio/ms228090(v=vs.100).aspx) and I will have asp files talking to them (those have specific urls you can use in your ajax calls) (http://stackoverflow.com/questions/4508409/ajax-method-call) and then use angularjs controllers to send the form data using ajax (see my links above) to asp files or c# handlers directly. AngularJS part is the same no matter what you have in the backend C#+ASP/Java Servlets+JSP/PHP/Python – Michail Michailidis Oct 27 '14 at 15:33