Yes you are true no need of setting explicit context.
Now I have removed it used the following code:
<wcm:initworkspace user="<%= request.getUserPrincipal() %>"/>
<%RenderingContext context = (RenderingContext)request.getAttribute(Workspace.WCM_RENDERINGCONTEXT_KEY);
String currentPath = context.getPath();
String subPath1 = currentPath.substring(currentPath.indexOf("/")+1);
String subPath2 = subPath1.substring(subPath1.indexOf("/"),subPath1.lastIndexOf("/"));
String subPath3 = subPath2.substring(subPath2.lastIndexOf("/"));
String currentLibrary ="Sample WCM";
Map myparams = new HashMap();
myparams.put("sitearea", currentLibrary+subPath2);
%>
<wcm:libraryComponent name="menu" library="Sample WCM" />
Still I am getting the same error.