aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes code written in scriptlet of JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "code written in scriptlet of JSP" Watch "code written in scriptlet of JSP" New topic
Author

code written in scriptlet of JSP

Prasad Kharkar
Ranch Hand

Joined: Mar 07, 2010
Posts: 446
    
    1

Hello all
I know that the scriptlet written in a JSP finally goes into the service method
but I want to know how we can call that method from a HTML form


like
when we write in HTML < form = "form1" action = "SampleServlet" method = "GET/POST" > for calling a servlet

what do we write for JSP?

SCJP 6 [86%], OCPWCD [84%], OCEJPAD [83%]
If you find any post useful, click the "plus one" sign on the right
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1715
    
  25

Hi Prasad,

I am not sure whether I am getting your question, but do you want to know how you can call the service method from a JSP?

Regards,
Frits
Prasad Kharkar
Ranch Hand

Joined: Mar 07, 2010
Posts: 446
    
    1

It can be a JSP or HTML also

I want to know
how we can call the JSP service method from the FORM tag of HTML
like to write METHOD = "GET" or METHOD = "POST" for servlets
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1715
    
  25

I want to know how we can call the JSP service method from the FORM tag of HTML

You can't call it directly.

(the http request is send from the client to the server and handled by the public service() method of the HttpServlet class, which dispatches the request to the protected service() method which dispatches the request to the doGet(), doPost() (also known as the doXXX ) methods defined in this class)

Regards,
Frits
Prasad Kharkar
Ranch Hand

Joined: Mar 07, 2010
Posts: 446
    
    1

so what should I write in the FORM tag?

method = "POST"
of
method = "GET"

I want to submit data so I need to use POST method, but if the code written in scriptlet goes into service method, what is the use of writing POST in FORM tag?
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1715
    
  25

I am still not getting you...

the "post" method in the HTML-form just corresponds with the doPost() method of your Servlet (a JSP is also turned into a Servlet)

can you post your html or jsp you want to create?

Regards,
Frits
Prasad Kharkar
Ranch Hand

Joined: Mar 07, 2010
Posts: 446
    
    1

Frits Walraven wrote:

the "post" method in the HTML-form just corresponds with the doPost() method of your Servlet (a JSP is also turned into a Servlet)




sir,
I know that JSP is turned into servlet

now for a HTML form to call a JSP on method POST, where should I write code in JSP?
if I write the code in scriptlet, then while converting to servlete, the code goes in service method, so how can I call the doPost method of JSP that is converted to servlet?


I have not written the code yet but will do it tomorrow morning

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42595
    
  65
so how can I call the doPost method of JSP that is converted to servlet?

By using POST as the method of the HTML form.

Using a JSP for processing is bad style, though, and you should not do that at all. Instead, write a servlet.


Ping & DNS - my free Android networking tools app
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1715
    
  25

if I write the code in scriptlet, then while converting to servlete, the code goes in service method, so how can I call the doPost method of JSP that is converted to servlet?

Ok, I am now getting your misunderstanding.

The code of a scriptlet in let's say JSP A is placed in the service method of the Servlet created from JSP A. Using a HTML form on the JSP A will issue a new request targeting another Servlet or JSP (depending on the action and the setup in your web.xml).

Regards,
Frits
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: code written in scriptlet of JSP