my dog learned polymorphism
The moose likes JSP and the fly likes simple questions Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "simple questions" Watch "simple questions" New topic
Author

simple questions

Anand Shrivastava
Ranch Hand

Joined: Jul 22, 2007
Posts: 125
I am new to web programming. I have got a simple project to make. From an SQL server database, i have to retrieve the marks obtained by students in an exam by sending their roll number and display the student's marksheet. Thats all.
Can someone tell me how i can make it. Whether it would require applet, servlet or JSP and what exactly should be done as i am completely new to the web field and this happens to be my first web assignment.


Anand Shrivastava
SCJA
Michael Ku
Ranch Hand

Joined: Apr 20, 2002
Posts: 510
are you asking that someone do this project for you by giving you the answer? It sounds like you were assigned to do something on your own but you do not want to do it yourself.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35254
    
    7
Michael,
I think you misread Anands question. He didn't say "please do it for me", he said "please tell me how to do it". Helping members to learn how to do things is what JavaRanch is all about, so I'd say his question is reasonable.

As to the question, neither applets nor JSPs are well suited for database access, so you should be using a servlet. For DB access you'll need to know JDBC, the Java API for accessing databases.

You can start learning about JDBC in the Java Tutorial, and about servlets in chapter 3 of the J2EE Tutorial.


Android appsImageJ pluginsJava web charts
Jetendra Ivaturi
Ranch Hand

Joined: Feb 08, 2007
Posts: 159
The task can be acheived thru any thing.

Eitehr applets or Jsp or servlets.

But prefer Jsp's and Servlets. As you said you are new to this. Its a good assignment to do.

Write a class which connects to the database. and using an input tag to take the student no. as input. fetch that input in that class. select * from markstable where stdno="+request.getParameter(std_no);

Display them in table fromat or what ever you like.

do remember abt the dirctory structure of web application.

Even I m sailing in the same ship.Got struck at a place. wtng for the response from mighties.
[ August 03, 2007: Message edited by: Bear Bibeault ]

SCJP 1.4 & 1.5, SCWCD 1.5. Learn and Let Learn.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56224
    
  13

Jetendra Ivaturi, please do not encourage people to take the conversation out of the forums. Please read this for more information.

Also, "abt" is not a real word. Please ue only real words like "about" when posting to the forums. Please read this for more information.
[ August 03, 2007: Message edited by: Bear Bibeault ]

[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56224
    
  13

As Ulf pointed out, JSPs are not intended for database access or any other type of processing. They should be used only to render the HTML display as part of a properly structured web application.
Anand Shrivastava
Ranch Hand

Joined: Jul 22, 2007
Posts: 125
Thanks for the replies.

I have done a bit of research on the net and i found that an applet can be used to take data from the client and then it can be transferred to the servlet through the output stream which in turn can be fetched by the servlet through the input stream, in servlet we can select the data from the database, serialize the object and send it back to the applet via the output stream which can be read by the applet through the input stream and then the data can be displayed.

Fair.

I have few questions though very primary for the experts but crucial for me :

(1) Now in all this applet servlet transaction what is the role of jsp ?
(2) if i use jsp, then will i not have to use applet?
(3) Whether a jsp can accept data from the client and without servlet fetch the data from the database ? or
(4) whether a jsp accepts the data from the client and sends a request to the servelet and gets the data to display to the client from servelet ?
(5) in this scenario what is the role of javascript i.e. what does it does ? (6) is javascript a substitute for applet ?
(7) as the data is in sqlserver database they are using IIS. Whether we can talk to IIS ?

kindly try to give pointwise reply. It would be very helpful.
Thanks.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I'd avoid an applet because they can be a bit tricky and they're not terribly common in the wild.

This is a pretty common structure:

It seems like a lot of moving parts but each one is well focused and simple.

Doing your GET and POST operations to a servlet is a natural, because a servlet is all Java, no HTML or JavaScript. It gets request fields out of the Request object and executes a POJO. "Plain Old Java Object" just means it doesn't import any servlet, JSP or HTTP stuff. It can call JDBC or whatever else it needs to do to get the data and return the data to the servlet. The servlet forwards to the JSP, which is all about HTML and little or ideally no Java. The JSP builds the response HTML.

I showed putting the data in a Request attribute to make it visible to the JSP. There are better ways to do that so the JSP can find and use the object as an ordinary bean. Somebody else will have to chime in with the details.

Does that look useful?


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Anand Shrivastava
Ranch Hand

Joined: Jul 22, 2007
Posts: 125
yes it is quite useful.
Thanks.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: simple questions
 
Similar Threads
hibernate.cfg.xml required in version 2.x?
selecting focus on load
What is a Session?
Calling WebService from a simple java class
JSP access to web service sunctionality