Questions about servlets Req and Res objects... - תכנות - HWzone פורומים
עבור לתוכן
  • צור חשבון

Questions about servlets Req and Res objects...


asihiz

Recommended Posts

1. In what way the Java Script code of the JSP page enters the sevlet?Meanin how doe's it transfer to the Res object?

2. HTML question - what is the meaning of submiting only one form and not the entire page?

3. Do I have to define a JSP page name in my HTML submit command?

4. If I submit via Post command (sending params via body of message) the header remains empty?

5. Is a JSP page can be loaded without a servlet?

6. If the answer to 5 is no, how do I know which JSP page belongs to which servlet?

7. Is the HTML in a JSP page is also loaded to a servlet? and if yes, how?

8. Saying I have a JSP page loaded to my servlet, and in a doGet method I enter a HTML code to the response object, where is this code added to? begginig of page? end? because I already have a JSP page loaded to the servlet and a response object is already have HTML in it.

9. Is a servlet an entry point for the server code?

קישור לתוכן
שתף באתרים אחרים

1. the java script code is not sent to the servlet, it only affects whats going on in the jsp itself, same way it does on a regular HTTP page.

2. when you submit only one form, then only the information in this form will be sent in the rerquest and not the entire page.

3. i'm not sure i got your meaning. you only define an input tag with 'type=submit'. you tell the submit what to activate in the form tag - action='/HelloWorldServlet' and in the servlet you can tell him to send the response to a page of your choice.

4. no. even via a GET request, the information is not transferred in the header, the header holds general information, such as the type of the message (text/html or mime type etc.)

5. yes. the jsp is not related to a certain servlet, you can even decide that one jsp will call another without any servlet involvement. you can treat the jsp as an ordinary HTML page.

6. the <form> tag has an 'action' attribute that tells the jsp what servlet (or other jsp) to call when the submit button is pressed

7. there are ways to parse a complete HTML page as an xml, but in general , the html is not sent to the servlet, only the parameters you define are sent. i.e.: <input type="text" name="id">, when you press the submit, the request will contain a parmeter called "id". the name of each "input" will bew sent as the 'key' and the value of the field will be the 'value'. so in the servlet you do: request.getParameter(id") and you'll get the value.

8. it depends wher you direct your servlet. if you don't give it any direction, it will open a new http page. if you send a response (and not use reponse.getWriter.writeprintln()) the data will be store in a reponse object (which you can access in the jsp) or you can store it in the session (if you want it to be saved through the all session and not just for the specific request)

9. i'm not sure i got your meaning. if you have other classes on the server and you want to acces them from the servlet then ,yes it is possible.you can also call a web service from the servlet. in general' the servlet 'lives' inside the server so you can call any code you have on the server.

from your questions i see you have a problem in understanding the basics of servlets and jsp's. i recommend you alittle bit and learn more of the subject before continuing any further. tru the sun tutorials, they are very good.

קישור לתוכן
שתף באתרים אחרים

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

×
  • צור חדש...