• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How will i make a servlet to generate jsp page dynamically

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi friends,

I am working on my college project...i am very much new to JSP & Servlets....and trying my best to make my project

now i am facing a problem that...i have thumbnails of movies on my website...if user clicks on a particular movie thumbnail....the all wallpapers for that movie gets displayed

like that i have first displayed many movie thumbnails....now one solution is that i will create a separate page for each movie wallpaper...so that if a user clicks on a specific movie thumbnail...he'll be transferred to the page linked to that image hyperlink...like this if i have 1 movie thumbnails...i have to create 1 pages for that movie wallpapers

but i am thinking if there is a way by which a servlet can create a jsp page dynamically n display movie wallpapers related to a particular thumbnail....when that thumbnail is clicked

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I can think of the following approach-
1)Store all your movie wallpapers in the corresponding movie directory.
2)pass the movie name/id to the jsp page that is going to display all the wallpapers for that movie.
3)the wall paper jsp page will iterate through the movie name and display the photos from the directory.

Hope this helps.

There might be better ways of doing this.

amit
 
Ranch Hand
Posts: 121
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

katreena thomas wrote:hi friends,

I am working on my college project...i am very much new to JSP & Servlets....and trying my best to make my project

now i am facing a problem that...i have thumbnails of movies on my website...if user clicks on a particular movie thumbnail....the all wallpapers for that movie gets displayed

like that i have first displayed many movie thumbnails....now one solution is that i will create a separate page for each movie wallpaper...so that if a user clicks on a specific movie thumbnail...he'll be transferred to the page linked to that image hyperlink...like this if i have 1 movie thumbnails...i have to create 1 pages for that movie wallpapers

but i am thinking if there is a way by which a servlet can create a jsp page dynamically n display movie wallpapers related to a particular thumbnail....when that thumbnail is clicked




You can do one thing here.
First create a database table which maps movie name to a wallpaper image URL
so will have many rows for a movie name.
Now when user clicks on thumbnail on JSP page fetch all the wallpaper image URL and show them.
 
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mrs. Katreena, you can do it like this. When ever you click on the movie thumbnail, it must have a unique ID. You must overwrite the url. It is called as URL rewriting.

Suppose consider this example



You must write a servlet which receives the request and reads the directory name. Then create a business logic that lists all the image files in that particular directory. Then store all the image names in a Bean and forward the request to a View(jsp).

see here to list all files in a directory

In that jsp read get the image names from the Bean and represent them using image tag.

I think you can understand what I say.

If you think this wrong approach please tell me so that I can rectify.

Have a nice day.
 
chaitanya karthikk
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jagdeep Sharma wrote:
You can do one thing here.
First create a database table which maps movie name to a wallpaper image URL
so will have many rows for a movie name.
Now when user clicks on thumbnail on JSP page fetch all the wallpaper image URL and show them.



Hi Mr. Jagdeep, your approach is right, but you don't need a database for this simple issue. Please let me know if I am wrong.

Have a nice day.
 
Jagdeep Sharma
Ranch Hand
Posts: 121
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

chaitanya karthikk wrote:

Jagdeep Sharma wrote:
You can do one thing here.
First create a database table which maps movie name to a wallpaper image URL
so will have many rows for a movie name.
Now when user clicks on thumbnail on JSP page fetch all the wallpaper image URL and show them.



Hi Mr. Jagdeep, your approach is right, but you don't need a database for this simple issue. Please let me know if I am wrong.

Have a nice day.




Hey Karthikk,
Then how you gonna do it. Do you have any better approach. How would you know for which movie which wallpapers to show.
 
chaitanya karthikk
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I already quoted an approach, see above
 
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using a DB is almost certainly overkill, seeing as this is a college project and katreena has said nothing about using one.

A file structure like the following should be sufficient (assuming that there are no movie titles to keep track of):

There would be one JSP page for displaying all thumbnails, and another one for displaying the wallpaper images for one particular movie. The latter would take the ID of the movie (1, 2, 3, etc.) as parameter.
 
Kate Thomas
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the suggestions....i am looking towards both of the approaches...but please provide me the code...i am not good enough in coding.....since its my first project in JSP & Servlet
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

katreena thomas wrote:please provide me the code...i am not good enough in coding


You're joking, right? You're assigned these projects precisely so that you learn how to program.
 
chaitanya karthikk
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Miss. Karteena, we wont offer code here, only the path is shown here, you have to code the things. You were saying that you are new to servlet and jsps, so you please read this textbook "Head first servlets and jsps". I suggest this book only for beginners because I also read the same book.
 
Does this tiny ad smell okay to you?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic