Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to approach news sections?  RSS feed

 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there

I am designing a Web Application Where there is a section of Latest News

Where I will display all those LatestNews in My latestNews.jsp file

I am thinking about its backend architecture
1)Call the latestNews table in database-->get all data and set them on Object-->and Forward request to JSP page-->Access data in JSP page show on front end

However problem with this approach is this if there is 10 news then data is Ok(Call from Servlet set 10 data on Objects)

But If there is 1000 news and user is intersted in only viewing top 50 or 100 then this will slow down web applications?

What I want is display all news when user scroll down.

One approach is place a link "Read More" then again a call to controller that will load all data and display on front end
and other is AJAX

So I am little bit confuse.What approach I should use?

Anyone has some good idea to handle this case?

Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66184
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An "infinite scroll" feature needs to be handled via Ajax. Otherwise, you need to fetch all possible elements up-front, and that just will not scale well.
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Bear

Thanks
You are awesome like other answars great answar to the point. :jumpingjoy:

One more thing I am not starting a new thread for it.(Because Question is related to this thread)
1)Their will be a Add News section that news will be add by admin.Its like News Papers(Link for Text,Video,Images)
So a kind of many threads of latest news.

How can I make this in java
Its somewhat like Javaranch forum but their will be Images also display on Home Page(Latest News)

How to do this?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66184
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are a lot of parts needed for that. Obviously forms for providing the text, uploading files and so on. Then there's how the media will be organized. Where will images be placed? Videos? And so on. Much too much to cover in a forum post. Start small with each part and ask questions as you go.
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will place Images and Media temporary in my directory before they are uploaded on server
and once they are uploaded into the server I will delete them from temporary directory

This is what I am thing so far

I want some code snipshot any link would be nice to a open source
Or an Idea or hint to organize to project is nice

I am thinking about dynamic view or div creation for different and each news based on infinite Scroll using AJAX
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66184
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as organization, it sounds like a straightforward web application like any other. See this article if you haven't already read it.

The most interesting part is the media. You can't store uploaded image and video assets within the application itself, so you need to figure out how you are going to handle that.
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is something close that I want

Can you guide me from where I should start in terms of JSP controller and database follow.

I am storing temp data in app and permananent in mysql database
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66184
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kishor Joshi wrote:Can you guide me from where I should start in terms of JSP controller and database follow.

That's exactly what the article I linked to is about.

I am storing temp data in app and permananent in mysql database

What temp data? Why is there any need for temp data? And never write anything into your web app. Web apps should be read-only.

I'd upload the assets (imagery and video) to a file system location outside the web app. Then, at least to start small, I'd stand up an simple file server (probably Apache) to serve those assets separately from the web app. Longer term, I'd look into using some object storage system such as Caringo (disclaimer: I work there) for enterprise, or S3 otherwise.
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By Viewing its Source
http://www.coderanch.com/t/649927/JSP/java/approach#2999787

I got some Information.
But I am not able to decide from where I should start?
Like what are the JSP?(So far I have thing one is thead.jsp and other is detail.jsp,createnewthread.jsp .

and then data from these will go to a controller and controller will Insert in the database.

However how a createnewthread.jsp I can design so that I can add Videos,Images and Text where I want?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66184
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are putting the cart ahead of the horse. There's much to do before you start thinking about JSPs. Do you have your model layer coded and tested? The best way to make sure that your model is independent of your UI is to code it first and separately. After that, you need to define the pages that will make up your application. Write the page and task controllers, and create HTML mockups of the pages. Those mockups can then be transformed into the JSP pages.

So I'd start by defining the requirements for the model, and then define the classes that will meet those requirements.
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok So I have started designing using JSP

One question
Can I make database call from JSP? or do I need to make a separte controller that will connect with database and do database tasks?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66184
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you read the article I linked to? It answers your question with a definitive NO. You shouldn't even be doing DB access from controllers. It should be deeply buried in the model.

Your model should be able to work WITHOUT any servlets or JSPs.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!