How to test the JSP pages and sevlets using JUnit. ?
How to test the JSP pages using JUnit. How to configure what are all the steps to execute the JUnit test cases.
Hi xiepei,
since you are using modbus, a simple error checking is implicit in the protocol and is the comparison between returned checksum and the calculated one on the received message: checksum errors, if any, are an effect of communications errors (you should have at least 2 bits changed and on particular patterns to have the checksum be calculated correctly!). You won't be able to calculate BER on them, but you can calculate PER (Packet Error Rate).
Another flag for communication errors, on the other direction, is to intercept error messages from the device: if it fully implements modbus protocol, it should return some warning in case of error (I seem to remember that in some cases it returns the reveived message with some error bits added: please check in modbus documentation).
Proud to use LW/CVI from 3.1 on.
My contributions to the Developer Zone Community
If I have helped you, why not giving me a kudos?
Similar Messages
-
How to get the jsp page name in jsp?
how to get the jsp page name in jsp? how the jsp get the jsp page name dynamic.
thanks in advance.Try request.getServletPath()
-
How to show the first page and then rest will be created in background
Dear Friends,
I am suffering from some seriouse issue of slow opening of report....
I am using vs2005 and asp.net 2.0 and crXI R2 sp4,
using oledb for getting data from ms sql server 2005.
Now my one report called accounts ledger
when i execute the report query it takes 1.03 mins for 515000 records..no issue with it ,
when i execute the report from report desginer for 515000 records its taking 26 mins . It is generating all
32000 pages.
Now same report i run from my web based erp application it takes 30mins to execute 32000 pages now
this is too much time it is taking and now our client is fedup of ussss..
So is there any way that we can show First page at the earliest and rest of the pages willl be getting created in background? is it possible ?
We have to give them the solution as sson as possible...
can anyone suggest the diff ways to get out of this problem .......
Please ur co operation will be appriciated....
thanskHi Mithun,
Here are a few points related to performance issue. These might be helpful.
The performance of a report is related to:
External factors:
1. The amount of time the database server takes to process the SQL query.
( Crystal Reports send the SQL query to the database, the database process it, and returns the data set to Crystal Reports. )
2. Network traffics.
3. Local computer processor speed.
( When Crystal Reports receives the data set, it generates a temp file to further filter the data when necessary, as well as to group, sort, process formulas, ... )
4. The number of records returned
( If a SQL query returns a large number of records, it will take longer to format and display than if was returning a smaller data set.)
Report design:
1. Where is the Record Selection evaluated?
Ensure your Record Selection Formula can be translated in SQL, so the data can be filter down on the server, otherwise the filtering will be done in a temp file on the local machine which will be much slower.
They have many functions that cannot be translated in SQL because they may not have a standard SQL for it.
For example, control structure like IF THEN ELSE cannot be translated into SQL. It will always be evaluated
in Crystal Reports. But if you use an IF THEN ELSE on a parameter, it will convert the result of the condition to
SQL, but as soon as uses database fileds in the conditions it will not be translated in SQL.
2. How many subreports the report contains and in section section they are located.
Minimise the number of subreports used, or avoid using subreports if possible because
subreports are reports within a report, and if you have a subreport in a details section, and the report returns 100
records, the subreport will be evaluated 100 times, so it will query the database 100 times. It is often the biggest
factor why a report takes a long time to preview.
3. How many records will be returned to the report.
Large number of records will slow down the preview of the reports. Ensure you only returns the necessary data on the report, by creating a Record Selection Formula, or basing your report off a Stored Procedure, or a Command Object that only returns the desired data set.
4. Do you use the special field "Page N of M", or "TotalPageCount"
When the special field "Page N of M" or "TotalPageCount" is used on a report, it will have to generate each page
of the report before it displays the first page, therfore it will take more time to display the first page of the report.
If you want to improve the speed of a report, remove the special field "Page N of M" or "Total Page Count" or formula that uses the function "TotalPageCount". If those aren't use when you view a report it only format the page requested. It won't format the whole report.
5. Link tables on indexed fields whenever possible.
6. Remove unused tables, unused formulas, unused running totals from the report.
7. Suppress unnecessary sections.
8. For summaries, use conditional formulas instead of running totals when possible.
9. Whenever possible, limit records through selection, not suppression.
10. Use SQL expressions to convert fields to be used in record selection instead of using formula functions.
For example, if you need to concatenate 2 fields together, instead of doing it in a formula, you can create a SQL Expression Field. It will concatenate the fields on the database server, instead of doing in Crystal Reports.
SQL Expression Fields are added to the SELECT clause of the SQL Query send to the database.
11. Using one command as the datasource can be faster if you returns only the desired data set. It can be faster if the SQL query written only return the desired data.
12. Perform grouping on server
This is only relevant if you only need to return the summary to your report but not the details. It will be faster as less data will be returned to the reports.
Regards,
Shweta -
How to change the master page and theme dynamically in sharepoint2013 anonymous site
hi
I have to change the master page and theme dynamically in sharepoint2013 anonymous site. i have to show one master page to authenticated user another master page to anonymous user through code
SrinivasHi Srinivas,
According to your description, my understanding is that you want to change the master page and theme dynamically based on the anonymous users or authenticated users.
Per my knowledge, there is not an OOB way to change the master page and theme dynamically.
SharePoint is based on Asp.net, as we know Asp.Net request processing is based on pipeline model, so we can delevlop a custom HttpModule to dynamic change the master page based on current logon user profile(using SP Object Model to get).
Another solution could be to use the SecurityTrimmed control that injects the CSS depending on global user permissions, more information, please refer to
it.
Some similar posts for your reference:
http://social.msdn.microsoft.com/Forums/office/en-US/c2b2d0da-c752-4aea-9c2d-e31a5b1a2988/sharepoint-2010-dynamic-masterpage-based-on-userprofile-property
http://johanleino.wordpress.com/2011/10/20/using-a-different-master-page-for-authenticated-users-in-sharepoint/
http://sharepoint.stackexchange.com/questions/21679/how-can-we-use-a-different-masterpage-for-annoymous-and-authenticated-users
http://sivarajan.me/post/How-to-customize-the-SharePoint-2013-Master-Page-for-Anonymous-Users
Best Regards,
Wendy
Wendy Li
TechNet Community Support -
How to Test the individualmapping field and conditions...
Hi Frnds,
I done mapping from source to destination as per tech spec in my scenario based on some conditions
i used node functions also..
But my question is how to test the every mapping filed , condition is correct or not, what i used node function working properly or not...
Regards,
RajHi
If you want to check mapping for individual mapping then in design go to test tab and put your data there and then come again on Design tab and click on any target field fro which you want to check mapping then right click on target field in mpping area and click on Display queue and check whether it is expected output for that particular field mapping.
Regards
Sami
Reward points if useful. -
How to get the total page number when using Crystal Report in JSP
In my JSP, I use the class CrystalReportViewer to generate and display the report views. But this class only sypply the function to get the info of the active view.
Thus with this info, I only can get the active view's page number. How can I get the report total page number without showing the last page first?
Thanks.Anything you do without submitting to form has to be done on the client side (ususally by JavaScript) using data which has been send already from the server.
With JavaScript you can do quite a bit. You can download tables which don't necessarilly appear on the screen, loading them into JavaScript arrays by dynamically generating javascript. Then you can pick up events like drop-box selection and use these tables to chose what you do next (e.g. preloading other fields, setting drop box content etc.).
Or, you can cause forms to be submitted when actions like a selection happen without the user clicking a button. It's generally a matter of how much data you'd need to transmit.
Another posibility is to use a Java applet, which can generate requests to the server and handle the results as it chooses. That are a number of problems with that but occasionally it's the best solution.
What you can't do is to handle user input inside a JSP. The JSP has come and gone before the user even gets to see your form. -
How to send the jsp page to .txt format
Hi All
Please suggest me how to create a .txt file using the desformat. My requirement is file should be saved as txt format and it will be sended by mail to be user pager. He can see the txt file through his pager. I tried several techniques but it not working.
I am using the following URL:
http://123.223 /reports/rwservlet? report=Admission.jsp&destype=file&desname=c:/demo/Admission.txt&userid=am/ampazz@tempdb
The above URL is correct or any changes required.
Pls suggest me…
Thanking all
Regards
SrinivasSome of the points might help you in thinking towards right direction, you might already know this but doesn't look like you are following in your code anyway.
1. The JSP that you are emailing is uncompiled source file. It need JVM environment to be able to run on.
2. The JSP is a view technology so try to separate the view logic from the business.
3. Try to put entire business logic in a Bean and use that in your JSP to start off with.
You may need to write the HttpServletResponse#content on to the Writer and then persist it on the filesystem. and then send that persisted file as an attachment.
Have a look at http://java.sun.com/j2se/1.5.0/docs/api/java/io/Writer.html
It provide different type of writer implementations.
HttpServletResponse#getWriter() provides PrintWriter instance.
Does it make sense? -
How to test the extended controller and AM Object
I added a button in a OAF page and extended the CO and AM. When we click this button, an XML Publisher concurrent program should be called and the PO will be displayed in PDF format.
What is the best way to test this. Should I copy all the libraries from oracle/apps/... to my pc and attach or can I test without doing this. If so, what is the best approach.
I am new to this.
Thanks for your Help.
HPI got the code ready for with extended Co java file. How can test this. How to generate the class file. Once I gerenarate the class file, if I ftp the file to cust/oracle/apps/pos/changeorder/webui and in the personalization if I attach this CO and run the page and click the button will this call the new CO? Yes after FTP the Contorller class file to appropriate path and attach the extended controller through personalization New Controller will get called.
But DO REMEMBER TO BOUNCE THE APPACHE SERVER then only the extended Controller file get called.
here is the link having steps to bounce it for Apps 11i.
http://oracleanil.blogspot.com/2009/04/ncrimmessageproc.html
Please let me know if these steps are correct..
1. New OAWorkSpace
2. New Project
3. right click on project and click New class to generate the extended CO Class.Yes, It is right..
Thanks
--Anil
http://oracleanil.blogspot.com -
How to send the jsp page with the data as attachment
hi
my application is to display all the datas from the database.In the same page. i'm having a option to select mail address from the combo box and to send the page with the same format thru mail as an attachment .
<% String from="192.168.10.1";
String to=request.getParameter("to");
System.err.println(to);
String mailhost="localhost";
System.err.println("hiiiiiiiii");
try
System.err.println("byeeeeeee");
Properties prop=System.getProperties();
prop.put("mail.smtp.host", mailhost);
Session ss=Session.getInstance(prop,null);
System.err.println("session props");
Message message = new MimeMessage(ss);
System.err.println("message");
message.setFrom(new InternetAddress(from));
System.err.println("form not null");
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
System.err.println("from and to r set");
message.setSubject("Hello JavaMail Attachment");
// Create the message part
BodyPart messageBodyPart = new MimeBodyPart();
// Fill the message
messageBodyPart.setText("have u got the attachement?");
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);
// Part two is attachment
messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource("C:/Program Files/Apache Software Foundation/Tomcat 5.0/webapps/MgmtTool/emsReport.jsp");
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName("emsReport.jsp");
multipart.addBodyPart(messageBodyPart);
// Put parts in message
message.setContent(multipart);
System.err.println("ready");
// Send the message
Transport.send(message);
out.println("mail was sent successfully");
catch(Exception e)
{out.println(e);}
%>
by using this code i 'm sending the emsreport page as attachment
i'm recieving only the tabular format but i cant able to get those data which are present on that page
i dont know wat to do???
kindly help me
thank u in advanceSome of the points might help you in thinking towards right direction, you might already know this but doesn't look like you are following in your code anyway.
1. The JSP that you are emailing is uncompiled source file. It need JVM environment to be able to run on.
2. The JSP is a view technology so try to separate the view logic from the business.
3. Try to put entire business logic in a Bean and use that in your JSP to start off with.
You may need to write the HttpServletResponse#content on to the Writer and then persist it on the filesystem. and then send that persisted file as an attachment.
Have a look at http://java.sun.com/j2se/1.5.0/docs/api/java/io/Writer.html
It provide different type of writer implementations.
HttpServletResponse#getWriter() provides PrintWriter instance.
Does it make sense? -
How to test the communication stability and calculate ber using the CVI ?
Our chief engineer gave me a task yeasterday.He asked me to do software testing and calculate bit error rate that we would know our communication stability.
However,I have never touched this aspect of knowledge. I have known a bit about CVI and I want to write bit error rate code using CVI.Thus,I could test the communication stability.
But I don't know how to analyse and judge the receiving codes whether they are right or wrong.
We use Modbus communication protocol and receive data via serial port,so I want to save all datas and record the total datas number ,marking as M.
then,save the eligible datas and record the mumber marking as N. So, bit error rate is (M-N)/M .
Whether this is feasible ? Or you have any good idea. Thank you very much.
unsigned char in_data[100];
inqlen = GetInQLen (comport);
for(i=0;i<inqlen;i++)
in_data[i]=ComRdByte(comport);
Above is my code that receive all datas and I want to save the array in_data[] data and record the number.
switch(inqlen)
case 19:
crc=usMBCRC16(in_data,inqlen );
if((in_data[1] == 0x03)&&(crc==0)&&(in_data[0]==device_addr))
Above is the condition judgement that receive eligible datas which number marks as N.
I know there is a precondition that I filter out all the wrong data . However ,I don't know any good idea. I will appreciate if anyone could help me.
Thank you very much.
Best regards.
xiepei
I wouldn't care success or failure,for I will only struggle ahead as long as I have been destined to the distance.
Solved!
Go to Solution.Hi xiepei,
since you are using modbus, a simple error checking is implicit in the protocol and is the comparison between returned checksum and the calculated one on the received message: checksum errors, if any, are an effect of communications errors (you should have at least 2 bits changed and on particular patterns to have the checksum be calculated correctly!). You won't be able to calculate BER on them, but you can calculate PER (Packet Error Rate).
Another flag for communication errors, on the other direction, is to intercept error messages from the device: if it fully implements modbus protocol, it should return some warning in case of error (I seem to remember that in some cases it returns the reveived message with some error bits added: please check in modbus documentation).
Proud to use LW/CVI from 3.1 on.
My contributions to the Developer Zone Community
If I have helped you, why not giving me a kudos? -
Fixed: How to remember the DataTable state and still use buttons
Lets say that you have a DataTable on a page, with a bunch of hyper links and buttons on the same page (for navigation to various parts of your application). If you use the built in pagination and sorting, you will find that the following behaviour:
1. DataTable remembers its state (sorting, page number, etc.) if you click on any hyper link. You can even go back to a different page, and then come back to the original page to find that your DataTable is in the state you left it (very cool, it is session scope and works as intended).
2. If you click on any button, DataTable does not remember its previous state (goes back to page 1 and default worting, etc.). After playing around with it and going nuts, I discovered the way to use Button and still have the DataTable remember its state. I wanted to share it with the rest of you:
public String btnClose_action() {
try {
this.getExternalContext().redirect("faces/users.jsp");
} catch (Exception ex) {
log("Error: userDetail > btnClose_action", ex);
return null;
}This was my original post:
http://swforum.sun.com/jive/thread.jspa?threadID=103583
Message was edited by:
SabirII think there should be a property
to disable form submission on buttons. There is!
To make the form not be submitted by a button click:
1. In the Visual Designer, select the button.
2. In the Properties window set the JavaScript > onClick property to return false;
This might interest you: http://blogs.sun.com/divas/entry/disabling_a_button_after_it -
How to parser a html page and get useful information?
now ,I try to get the page by the url,after getting the whole page,
is there any way to get the useful text ,and abandon other ,liks ,ad likes,
other related links?
I try to use java.util.regex.*;
is there any other methods for dointg this?Regex isn't a good method unless your requirements are quite simple. In general if you want a Java HTML parser they are not hard to find -- "java html parser" is a good choice of keywords for an internet search.
-
Can any body tell me how to map the jsp page with sling servlet
here is my content.jsp
<%@include file="/libs/foundation/global.jsp"%>
<cq:include script="/libs/wcm/core/components/init/init.jsp"/>
<div>
<h3>Login</h3>
<form name="frm" method="doGet" action="/LoginServlet">
<cq:include path="texot" resourceType="sapphirenow_web/components/foundation/textlog"/>
<cq:include path="text1" resourceType="sapphirenow_web/components/foundation/textlog"/>
<cq:include path="text3" resourceType="sapphirenow_web/components/foundation/submit"/>
</form>
</div>
here is my LoginServlet.java
package com.sapphirenow.web;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;
import javax.servlet.ServletException;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
* @scr.component metatype="true"
* @scr.service interface="javax.servlet.Servlet"
* @scr.property name="sling.servlet.paths" value="/bin/mn"
* @scr.property name="sling.servlet.methods" values="GET"
public class LoginServlet extends SlingAllMethodsServlet
public void doGet(SlingHttpServletRequest request,SlingHttpServletResponse response) throws ServletException,IOException
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String name = request.getParameter("Username");
String pass = request.getParameter("Password");
out.println("<html>");
out.println("<body>");
out.println("Thanks Mr." + " " + name + " " + "for visiting roseindia<br>" );
out.println("Now you can see your password : " + " " + pass + "<br>");
out.println("</body></html>");
its showing "The requested URL /LoginServlet was not found on this server." how to solve this pls help meHi,
Bellow some links which maybe hepls you:
-> http://sling.apache.org/site/manipulating-content-the-slingpostservlet-servletspost.html
-> http://edivad.wordpress.com/2011/07/18/cq-sling-servlets-resourcetype/
-> http://sling.apache.org/site/servlets.html
-> http://blogs.adobe.com/aaa/tag/sling
and some threads from the forum:
-> http://forums.adobe.com/message/4943006#4943006
-> http://forums.adobe.com/message/4915799#4915799
By the way there is a lot of information which you can find in th network.
Regards,
kasq -
How to return the JSP page name
Hello guys:
for some reasons,i want show the page name on itself,but it always return NULL when use request.getPathInfo().
ThanksHiii,
If you want the relative path....then the following will do the job.
String vPath = request.getRequestURI();
Otherwise you can get the whole path with the use of following.
String rPath = getServletConfig().getServletContext().getRealPath("/your.jsp")
Hope that helps. -
How to get the system date and time using java
hi,
I want system date in my out put. how to access system date. can v use utill packaegs (or) sql. which one is the best to get.
Thanks & Regards,
Kenny.import java.util.Date;
import java.util.Calendar;
import java.util.GregorianCalendar;
public class MyClass {
public void setTimeStamp() {
int hour, minute, second, time = 0;
Date dt=new Date();
System.out.println(dt.getDate());
System.out.println(dt.getMonth());
System.out.println(dt.getYear());
Calendar cal = new GregorianCalendar();
hour = cal.get(Calendar.HOUR_OF_DAY);
minute = cal.get(Calendar.MINUTE);
second = + cal.get(Calendar.SECOND);
System.out.println (hour + ":" + minute + ":" + second);
public static void main (String args[]){
MyClass app = new MyClass();
app.setTimeStamp();
}
Maybe you are looking for
-
Boot Camp: Windows stuck on startup when external hard drive is attached
Hi all, I have Windows XP installed with Boot Camp. All was working fine (even though I installed Service Pack 3 and THEN the Boot Camp update), but today I received an external hard drive I ordered for use with Time Machine. It's a Western Digital M
-
Please help if you can.
-
Hello I want to just write a simple Labview program that would take an input from user (The input must be limited e.g creating a drop down menu). Then based on this input, it must ask user to enter other inputs. for example. Input 1. can be either a
-
Export progress bar shows, but no SWF appears
Hello all, i've been through tech support and about 100 different sites with this issue but nothing seems to help. I'm using windows Vista 64 bit (work machine, not personal) with Adobe CS5 production premium. I have this training I created in flash
-
Revision: 5289 Author: [email protected] Date: 2009-03-12 21:09:58 -0700 (Thu, 12 Mar 2009) Log Message: Fix for - HTML tags in tags in ASdoc comments not being parsed correctly. QE Notes: Some baseline will require update. Doc Notes: None. Bugs: SDK