29-Dec-04 (Created: 29-Dec-04) | More in 'Questions'

Questions, Feedback 1 - 8/13/2004 - 12/25/2004

>> Wednesday, October 13, 2004 2:49:13 PM - Comments by satya

Should I use a servlet or a JSP?

Should I use a servelt or a JSP to do my work. Which is preferable?

- Mahaveer

>> Wednesday, October 13, 2004 5:06:02 PM - Comments by satya

If you are playing around with things as what servlets can do, JSP is not a bad option. In JSP, you just write a jsp page and put it in the path and you are ready to go. But JSPs gets compiled at run time so you won't know if there is anything wrong with JSPs until you access them.

Servlets on the other hand gives a compile time environment and a finer control over what you want to do. But to effectively work with servlets you need a java IDE and also preferably you have to define them to the servlet container via the web.xml file.

JSPs being optimized for presentation they are not suited for business logic that much. Mainly exception handling and IDE support comes in the way.

So what people normally do is to use only a limited number of servlets for a website and have these servlets process data and then call a JSP page for painting the data. For example all web requests can be sent to a single servlet called a controller servlet and then the controller servlet based on some configuration call a java class that does the action and collect data and then forward the request to a JSP page. This type of architecture is called the Model 2 architecture.

In Aspire for instance there are three servlets. One for displaying data and one for updating data and one for testing purposes. Potentially you can get away with one. But I have three.

Please do respond if you have any follow up questions

Satya

>> Friday, October 15, 2004 11:14:52 AM - Comments by sarayu

Mailing from JSP

I had used the Absolute path for getting the URLStringReaderPart like http://localhost:8080/.... but i found the same error like

info: root cause - com.ai.application.interfaces.RequestExecutionException:Error: reading url:http://localhost:8080/....

>> Friday, October 15, 2004 10:36:33 AM - Comments by satya

Ramesh, Please append here the properties file and also the exception trace from the log file. I will also check my email if you have emailed that stuff.

Were you able to type that url in the browser and saw your web page on the screen?

Satya

>> Friday, October 15, 2004 10:58:26 AM - Comments by satya

Ramesh, I have just tested it with the following

request.TestReader.classname=com.ai.parts.URLStringReaderPart
request.TestReader.URL=http://localhost:8181/akc/index.html
request.TestReader.resultName=test

See if you can do something similar with a known working url. Pay attention to the log file and try to get to the root cause. See the java trace.

You can cut and paste your log file here if you put them between pre tags. Here is an example

example line1
example line 2

Satya

>> Saturday, October 16, 2004 12:04:04 PM - Comments by sarayu

Mailing from JSP

sir Iam sending the properties file and the log file for checking the errors

DisplayURL=/jsp/display.jsp DisplayURL.formHandlerName=DisplayURLFORM DisplayURL.transformType=jsp request.DisplayURL.transform.className=com.ai.jsp.JSPTransform request.DisplayURLFORM.form_handler.class_request.className=com.ai.htmlgen.DBHashTableFormHandler1 request.DisplayURLFORM.mainDataRequest.className=com.ai.db.DBPreTranslateArgsMultiRequestExecutor request.DisplayURLFORM.mainDataRequest.db=testDB request.DisplayURLFORM.mainDataRequest.query_type=select request.DisplayURLFORM.mainDataRequest.request.1=getdeltab2 request.DisplayURLFORM.mainDataRequest.request.2=getbilltab2 request.getdeltab2.className=com.ai.db.DBRequestExecutor2 request.getdeltab2.query_type=select request.getdeltab2.stmt= \ SELECT Order_id as idD,C_name as NameD,Street as StD,City as CiD,State as StaD,Country as CouD,Zip as ZipD,Phone as PhD,Mobile as MobD,Email as EmD from order_del where Order_id={ordid} request.getbilltab2.className=com.ai.db.DBRequestExecutor2 request.getbilltab2.query_type=select request.getbilltab2.stmt= \ SELECT Order_id as idB,C_name as NameB,Street as StB,City as CiB,State as StaB,Country as CouB,Zip as ZipB,Phone as PhB,Mobile as MobB,Email as EmB from order_bill where Order_id={ordid} DisplayURLFORM.loopNames=cartdetailsloop2 #request.DisplayURLFORM.cartdetailsloop2.class_request.className=com.ai.htmlgen.RandomTableHandler7 request.DisplayURLFORM.cartdetailsloop2.class_request.className=com.ai.htmlgen.GenericTableHandler6 request.DisplayURLFORM.cartdetailsloop2.query_request.className=com.ai.db.DBRequestExecutor2 request.DisplayURLFORM.cartdetailsloop2.query_request.db=testDB request.DisplayURLFORM.cartdetailsloop2.query_request.stmt= \ SELECT product_id,pname,user_id,qty,size,color from basket where user_id = {useid1} #Identify the server side action #In this case it is a pipeline request.sendMailRequest.classname=com.ai.db.DBPreTranslateArgsMultiRequestExecutor request.sendMailRequest.db=testDB #Identify where to go next request.sendMailRequest.redirectURL=http://localhost:8080/avada/display?url=DisplayURL&ordid={ordid}&useid1={useid1} request.sendMailRequest.failureRedirectURL=http://localhost:8080/avada/display?url=FailCartURL ## Define the pipeline request.sendMailRequest.request.1=GetFromToSubject request.sendMailRequest.request.2=GetBodyText request.sendMailRequest.request.3=FinalSendMail ## Get from, to, and subject fields request.GetFromToSubject.classname=com.ai.db.DBRequestExecutor2 request.GetFromToSubject.db=testDB request.GetFromToSubject.stmt=\ select toadd as to1,fromadd as from1,sub as subject from usertable1 where useid={useid1} # GetBodyText # USing the URLStringReader to retrieve a url as a string request.GetBodyText.classname=com.ai.parts.URLStringReaderPart request.GetBodyText.URL=http://localhost:8080/avada/display?url=DisplayURL&ordid={ordid}&useid1={useid1} request.GetBodyText.resultName=bodyText ##Expected inputs ##from, to, subject, bodyText #Finally invoke the mail executor to send the mail request.FinalSendMail.classname=com.ai.aspire.utils.MailRequestExecutor request.FinalSendMail.smtpMailHost=smtp.eth.net request.FinalSendMail.user=******* request.FinalSendMail.password=*******

and this is the log file where i got the errors...

Arguments in to the statement are : {url=DisplayURL, request_name=sendMailRequest, aspire_response=org.apache.coyote.tomcat5.CoyoteResponseFacade@1faa614, aspire_request=org.apache.coyote.tomcat5.CoyoteRequestFacade@ad7d80, profile_uid=2, useid1=2, ordid=3434, sendmail=SendMail, aspire_session=org.apache.catalina.session.StandardSessionFacade@a6d35, aspire.reserved.jdbc_connection=com.mysql.jdbc.Connection@1533c8, aspirecontext=avada, prodid1=20, profile_user=annonymous} 10/15/04 10:39 AM: statement to execute : select toadd as to1,fromadd as from1,sub as subject from usertable1 where useid=2 10/15/04 10:39 AM: Trace:RSDataRow/getValue Request for column index 0 10/15/04 10:39 AM: Trace:RSDataRow/getValue return [email protected] 10/15/04 10:39 AM: Trace:RSDataRow/getValue Request for column index 1 10/15/04 10:39 AM: Trace:RSDataRow/getValue return [email protected] 10/15/04 10:39 AM: Trace:RSDataRow/getValue Request for column index 2 10/15/04 10:39 AM: Trace:RSDataRow/getValue return value=congratulation ramesh 10/15/04 10:39 AM: Info:RSDataRow/getValue request for column to1 10/15/04 10:39 AM: vectorMetadata: Request for column : to1 10/15/04 10:39 AM: vectorMetadata: Returned index for column : 0 10/15/04 10:39 AM: Info:RSDataRow/getValue request for column from1 10/15/04 10:39 AM: vectorMetadata: Request for column : from1 10/15/04 10:39 AM: vectorMetadata: Returned index for column : 1 10/15/04 10:39 AM: Info:RSDataRow/getValue request for column subject 10/15/04 10:39 AM: vectorMetadata: Request for column : subject 10/15/04 10:39 AM: vectorMetadata: Returned index for column : 2 10/15/04 10:39 AM: Creating the creator :com.ai.parts.URLStringReaderPart 10/15/04 10:39 AM: Info:BaseServlet servicing: http://localhost:8080/avada/display 10/15/04 10:39 AM: Inside get user 10/15/04 10:39 AM: auth: Http authentication active 10/15/04 10:39 AM: Authorization :null 10/15/04 10:39 AM: db: Could not execute the request for : request.sendMailRequest 10/15/04 10:39 AM: cp: Returning connection for pool testDB 10/15/04 10:39 AM: com.ai.application.interfaces.RequestExecutionException:Error: reading url:http://localhost:8080/avada/display?url=DisplayURL&ordid=3434&useid1=2 com.ai.db.DBException:RequestExecution failed com.ai.application.interfaces.RequestExecutionException:A database error is being reported com.ai.application.interfaces.RequestExecutionException: com.ai.application.interfaces.RequestExecutionException:Error: reading url:http://localhost:8080/avada/display?url=DisplayURL&ordid=3434&useid1=2 com.ai.db.DBException:RequestExecution failed com.ai.application.interfaces.RequestExecutionException:A database error is being reported at com.ai.db.DBBaseJavaProcedure.executeRequest(DBBaseJavaProcedure.java:240)

I had checked by copying the URLStringReaderPart as http://localhost:8080/avada/display?url=DisplayURL&ordid=3434&useid1=2 iam able to see the page but by the program iam getting the error i could not get the problem sir,

Thank You Sir,

Ramesh