Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Yet another MVC question

 
ravil baizhiyenov
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good morning (... day, evening) ranchers.

I have yet another MVC question. I can't always wrap my mind around it, because I'm fairly new to the concept...
Anyways. Please take a look at the following image and let me know if you have any suggestions as of how to better implement the solution:



It should provide searching capabilities for a SQL database.
search.jsp - displays the form, sends it to the servlet and should display the results. VIEW
search.do - servlet that receives data and prepares the response by accessing a few java classes CONTROLLER
dbConn.java - connects to the db MODEL
validate.java - checks user input MODEL
searchDTO.java - data class (to store individual results), will be a member of ArrayList MODEL

Please let me know if I got the concept right....

Also, please suggest a way to send the results to jsp... (On jsp, I guess, I will use jstl to render the results.)

Thank you very much, any help would be appreciated!
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya. it is fine to me with one changes in your order . dbConn.java - connects to the db MODEL[DAO] should come after the validate.java - checks user input MODEL[related to the controller][carefully see the steps in your diagram ]
 
ravil baizhiyenov
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
seetharaman venkatasamy wrote:ya. it is fine to me with one changes in your order . dbConn.java - connects to the db MODEL[DAO] should come after the validate.java - checks user input MODEL[related to the controller][carefully see the steps in your diagram ]


Thanks for your response!

I actually do verify user input before querying the database. If it isn't valid, I go straight to step 6 (i.e. send error msg to jsp).

The only thing that I don't really know yet, is what is the most efficient way to send the response to jsp... Should I use a RequestDispatcher (which is sort of confusing to me), or something else?

On my other jsp page I access DAO object directly through jstl to populate a drop down. However, in this case I don't think that I can do so, because it complicates things..
 
ravil baizhiyenov
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lol

Happen to close my own topic again =)

Anyways, I guess, just for the reference of whoever will be looking for a similar solution, I will post what I found...

The two most convenient ways to pass data is either through session, or forwarding request (using RequestDispatcher). I used the second method. Quick example can be found here: http://onjava.com/pub/a/onjava/excerpt/java_cookbook_ch18/index.html?page=8.
In my case I pass ArrayList to jsp and then iterate through it using jstl...

If you have any comments, you're welcome to post them here.

Now... If someone gave me a hint how to implement paging.... =)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic